Skip to content

Build fails with fs.read entitlement error when dockerfile is outside the build context (buildx >= 0.37.2) #14285

Closed

Description

@arndttouby

Description

Since buildx v0.37.2 (GHSA-gwr2-q96m-6682), buildx bake --progress rawjson enforces filesystem entitlements instead of skipping the consent check. Compose always invokes bake that way, but localBuildPaths in pkg/compose/build_bake.go only grants --allow fs.read= for build.context and build.additional_contexts — not for build.dockerfile. A service whose Dockerfile lives outside its build context therefore no longer builds. Before buildx v0.37.2 the missing grant went unnoticed because the check was skipped under rawjson.

This breaks every Dev Container that uses a Compose service with build:: the devcontainer CLI writes Dockerfile-with-features into a temp directory and points dockerfile: at it through an override file (dockerCompose.ts), which fails with:

additional privileges requested: pass "--allow=fs.read=/private/var/folders/…/T/devcontainercli/container-features/0.76.0-…/Dockerfile-with-features" to grant requested privileges

The code is unchanged in v5.6.0 and on main.

Steps To Reproduce

mkdir -p /tmp/outside && echo 'FROM alpine' > /tmp/outside/Dockerfile
mkdir -p /tmp/repro && cd /tmp/repro
cat > compose.yaml <<'EOF'
services:
  app:
    build:
      context: .
      dockerfile: /tmp/outside/Dockerfile
EOF
docker compose build
[+] Building 0.0s (1/1) FINISHED
 => [internal] load local bake definitions                         0.0s
 => => reading from stdin 466B                                     0.0s
[+] build 0/1
 ⠋ Image repro-app Building                                        0.1s
additional privileges requested: pass "--allow=fs.read=../outside/Dockerfile" to grant requested privileges

Compose Version

Docker Compose version v5.5.1

Docker Environment

macOS (Apple Silicon), Docker Desktop 4.94.0 (241994), buildx v0.37.2

Anything else?

Workaround: BUILDX_BAKE_ENTITLEMENTS_FS=0, which disables the check for all paths.
Suggested fix: add the resolved Dockerfile path to the fs.read allowlist when it is a local path outside the context (dockerfile_inline is unaffected).

Activity

  1. simon360 commented on Oct 7, 2026

    @simon360

    The same thing applies for secrets that are outside of the working directory. For example, we have some pip packages on a private repository in Google Cloud Artifact Registry, so at build time, we need the google cloud credentials. We do that with a secrets block in the docker-compose.yml file:

    services:
        main:
            environment:
                - GOOGLE_APPLICATION_CREDENTIALS=/tmp/keys/application_default_credentials.json
            build:
                context: .
                secrets:
                    - gcloud
    
    secrets:
        gcloud:
            file: ~/.config/gcloud/application_default_credentials.json
    

    And then, in the Dockerfile, we have this:

    RUN --mount=type=secret,id=gcloud,target=/root/.config/gcloud/application_default_credentials.json,required=false \
        poetry install
    

    This worked until the same change mentioned in the original submission came into play. Now, when we try to build, we get this error:

    additional privileges requested: pass "--allow=fs.read=/Users/<redacted>/.config/gcloud/application_default_credentials.json" to grant requested privileges
    

    We've worked around it by adding:

    additional_contexts:
      gcloud-config: ~/.config/gcloud
    

    under the build block, which forces Compose to include ~/.config/gcloud in the localBuildPaths, but this isn't ideal. It grants a larger scope than is necessary, since it's adding read-only permission for the whole gcloud directory, when we only need the signle JSON file.

  2. marlonramirez commented on Oct 7, 2026

    @marlonramirez

    Windows data point: I hit the same "additional privileges requested" failure on Windows 10 Pro 22H2 (Docker Desktop 4.94.0, Compose v5.5.1, buildx v0.37.2) in two situations.

    1. VS Code Dev Containers (extension 0.469.0): the override points dockerfile: at C:\Users\...\AppData\Local\Temp\devcontainercli\container-features\...\Dockerfile-with-features, outside the build context. This matches the issue. The real error only shows with docker --debug compose --progress plain ... build; otherwise Compose prints just failed to execute bake: exit status 1.

    2. Plain docker compose -f d:\path\to\docker-compose.yml build, with the Dockerfile inside the context. With a lowercase drive letter it fails; with D:\ it works. Debug output shows --allow fs.read=d:\...\.devcontainer while the Dockerfile is resolved as D:\...\Dockerfile, which is the path reported as missing.

    Reading the diff in #14286, the resolved Dockerfile path now gets its own grant, so case 2 should be covered too, as long as dockerFilePath returns the same string that is passed to bake as dockerfile. It may be worth adding a Windows test with a lowercase drive letter in the context path.

    BUILDX_BAKE_ENTITLEMENTS_FS=0 works around both.

  3. rcollette commented on Oct 8, 2026

    @rcollette

    We secret mount our JFrog credentials from our local maven settings at ~/.m2/settings.xml which is outside the project directory. This was an unexpected breaking change. Copilot CLI with Opus 5.5 even on autopilot does not want to use BUILDX_BAKE_ENTITLEMENTS_FS=0, without a user present, which is a major hang up for agentic development.

  4. omer-hadari-cyera commented on Oct 11, 2026

    @omer-hadari-cyera

    network.host in build.entitlements seems to not be passed to —allow either which is also broken since this buildx version.

  5. thaJeztah commented on Oct 11, 2026

    @thaJeztah
    Member
  6. crazy-max commented on Oct 12, 2026

    @crazy-max
    Member

    This comes from the fix for GHSA-gwr2-q96m-6682 in Buildx v0.37.2. Compose invokes Bake with --progress rawjson, which previously skipped entitlement enforcement, so the missing grants went unnoticed.

    GHSA-p54p-jq4x-rc28 was fixed in the same release but concerns implicit secret file sources and local OCI layout contexts. The secret examples above use explicit file sources, so those failures also come from enforcing the grants under rawjson.

    Compose needs to pass the grants for the configured Dockerfile and secret paths, along with --allow network.host when requested. Setting the entitlement in the Bake target doesn't grant it, and BUILDX_BAKE_ENTITLEMENTS_FS=0 won't help with network.host.

    Seems #14286 covers the Dockerfile case, but we'll also need to address the secret and network.host cases reported here.

  7. focdanisch commented on Oct 12, 2026

    @focdanisch

    I guess that this issue might occur for

    ssh:
      - my_id=/path/to/.ssh/id_ed25519
    

    as well...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions