Moderate severityGHSA Advisory· Published Oct 9, 2024· Updated Mar 18, 2026
Buildah: buildah allows arbitrary directory mount
CVE-2024-9675
Description
A vulnerability was found in Buildah. Cache mounts do not properly validate that user-specified paths for the cache are within our cache directory, allowing a RUN instruction in a Container file to mount an arbitrary directory from the host (read/write) into the container as long as those files can be accessed by the user running Buildah.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
github.com/containers/buildahGo | < 1.38.0 | 1.38.0 |
Affected products
1- Range: < 1.38.0
Patches
1aa67e5d71ee7Merge pull request #5778 from mheon/fix_cve_2024_9675
2 files changed · +48 −5
internal/volumes/volumes.go+14 −5 modified@@ -22,6 +22,7 @@ import ( "github.com/containers/storage/pkg/idtools" "github.com/containers/storage/pkg/lockfile" "github.com/containers/storage/pkg/unshare" + digest "github.com/opencontainers/go-digest" specs "github.com/opencontainers/runtime-spec/specs-go" selinux "github.com/opencontainers/selinux/go-selinux" ) @@ -374,7 +375,11 @@ func GetCacheMount(args []string, _ storage.Store, _ string, additionalMountPoin return newMount, nil, fmt.Errorf("no stage found with name %s", fromStage) } // path should be /contextDir/specified path - newMount.Source = filepath.Join(mountPoint, filepath.Clean(string(filepath.Separator)+newMount.Source)) + evaluated, err := copier.Eval(mountPoint, string(filepath.Separator)+newMount.Source, copier.EvalOptions{}) + if err != nil { + return newMount, nil, err + } + newMount.Source = evaluated } else { // we need to create the cache directory on the host if no image is being used @@ -391,11 +396,15 @@ func GetCacheMount(args []string, _ storage.Store, _ string, additionalMountPoin } if id != "" { - newMount.Source = filepath.Join(cacheParent, filepath.Clean(id)) - buildahLockFilesDir = filepath.Join(BuildahCacheLockfileDir, filepath.Clean(id)) + // Don't let the user control where we place the directory. + dirID := digest.FromString(id).Encoded()[:16] + newMount.Source = filepath.Join(cacheParent, dirID) + buildahLockFilesDir = filepath.Join(BuildahCacheLockfileDir, dirID) } else { - newMount.Source = filepath.Join(cacheParent, filepath.Clean(newMount.Destination)) - buildahLockFilesDir = filepath.Join(BuildahCacheLockfileDir, filepath.Clean(newMount.Destination)) + // Don't let the user control where we place the directory. + dirID := digest.FromString(newMount.Destination).Encoded()[:16] + newMount.Source = filepath.Join(cacheParent, dirID) + buildahLockFilesDir = filepath.Join(BuildahCacheLockfileDir, dirID) } idPair := idtools.IDPair{ UID: uid,
tests/bud.bats+34 −0 modified@@ -6971,3 +6971,37 @@ _EOF run_buildah 125 build $WITH_POLICY_JSON ${TEST_SCRATCH_DIR} expect_output --substring "invalid mount option" } + +@test "build-check-cve-2024-9675" { + _prefetch alpine + + touch ${TEST_SCRATCH_DIR}/file.txt + + cat > ${TEST_SCRATCH_DIR}/Containerfile <<EOF +FROM alpine +RUN --mount=type=cache,id=../../../../../../../../../../../$TEST_SCRATCH_DIR,target=/var/tmp \ +ls -l /var/tmp && cat /var/tmp/file.txt +EOF + + run_buildah 1 build --no-cache ${TEST_SCRATCH_DIR} + expect_output --substring "cat: can't open '/var/tmp/file.txt': No such file or directory" + + cat > ${TEST_SCRATCH_DIR}/Containerfile <<EOF +FROM alpine +RUN --mount=type=cache,source=../../../../../../../../../../../$TEST_SCRATCH_DIR,target=/var/tmp \ +ls -l /var/tmp && cat /var/tmp/file.txt +EOF + + run_buildah 1 build --no-cache ${TEST_SCRATCH_DIR} + expect_output --substring "cat: can't open '/var/tmp/file.txt': No such file or directory" + + mkdir ${TEST_SCRATCH_DIR}/cve20249675 + cat > ${TEST_SCRATCH_DIR}/cve20249675/Containerfile <<EOF +FROM alpine +RUN --mount=type=cache,from=testbuild,source=../,target=/var/tmp \ +ls -l /var/tmp && cat /var/tmp/file.txt +EOF + + run_buildah 1 build --security-opt label=disable --build-context testbuild=${TEST_SCRATCH_DIR}/cve20249675/ --no-cache ${TEST_SCRATCH_DIR}/cve20249675/ + expect_output --substring "cat: can't open '/var/tmp/file.txt': No such file or directory" +}
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
29- access.redhat.com/errata/RHSA-2024:8563ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8675ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8679ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8686ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8690ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8700ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8703ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8707ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8708ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8709ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8846ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8984ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:8994ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:9051ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:9454ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2024:9459ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2025:2445ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2025:2449ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2025:2454ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2025:2701ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2025:2710ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2025:3301ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2025:3573ghsavendor-advisoryx_refsource_REDHATWEB
- github.com/advisories/GHSA-586p-749j-fhwpghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2024-9675ghsaADVISORY
- access.redhat.com/security/cve/CVE-2024-9675ghsavdb-entryx_refsource_REDHATWEB
- bugzilla.redhat.com/show_bug.cgighsaissue-trackingx_refsource_REDHATWEB
- github.com/containers/buildah/commit/aa67e5d71ee7ec07122a210baa3b13966a9e086cghsaWEB
- pkg.go.dev/vuln/GO-2024-3186ghsaWEB
News mentions
0No linked articles in our index yet.