Skip to content

build: avoid empty source policy sessions - #4028

Merged
tonistiigi merged 1 commit into
docker:masterfrom
crazy-max:fix-noop-source-policy-session
Aug 25, 2026
Merged

build: avoid empty source policy sessions#4028
tonistiigi merged 1 commit into
docker:masterfrom
crazy-max:fix-noop-source-policy-session

Conversation

@crazy-max

@crazy-max crazy-max commented Aug 20, 2026

Copy link
Copy Markdown
Member

Remote Git contexts can enqueue an optional Dockerfile.rego lookup even when the build doesn't include a policy file. When that optional file was absent, Buildx resolved zero policy files but still attached a no-op SourcePolicyProvider, which made the solve request carry a SourcePolicySession. That matters for builders created with proxyNetwork = true, because BuildKit treats the presence of a source policy session as part of proxy-network enforcement, so a Git-context could fail with a proxy 403 Forbidden even though the same target succeeded from a local context.

The issue is reproducible with:

docker buildx bake --no-cache --builder <builder> "https://github.com/crazy-max/docker-github-builder.git?ref=proxy-network&subdir=test" proxy-network

against a docker-container builder using moby/buildkit:v0.32.2 and proxyNetwork = true.

This change keeps SourcePolicyProvider unset when policy resolution loads no policy files, so builds without policies don't accidentally opt into source-policy session behavior.

@crazy-max crazy-max added this to the v0.37.0 milestone Aug 20, 2026
@crazy-max
crazy-max requested a review from tonistiigi August 20, 2026 13:26
@crazy-max
crazy-max marked this pull request as ready for review August 20, 2026 13:26
@crazy-max
crazy-max force-pushed the fix-noop-source-policy-session branch from 5c390b2 to ed838db Compare August 20, 2026 13:47

@tonistiigi tonistiigi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good but the new test testBakeRemoteGitNoPolicyWithProxyNetwork seems to pass with or without the patch.

@crazy-max
crazy-max force-pushed the fix-noop-source-policy-session branch from ed838db to 4befbc5 Compare August 21, 2026 15:56
@crazy-max
crazy-max force-pushed the fix-noop-source-policy-session branch from 4befbc5 to b62b768 Compare August 21, 2026 16:03
@crazy-max

crazy-max commented Aug 21, 2026

Copy link
Copy Markdown
Member Author

Change looks good but the new test testBakeRemoteGitNoPolicyWithProxyNetwork seems to pass with or without the patch.

Ah yes it passed without the fix because the request was plain HTTP, and the empty source policy session didn't make that path fail.

The exec step now calls a local TLS server with wget --no-check-certificate. Without the fix, BuildKit returns HTTP/1.1 403 Forbidden before the request reaches the test server.

I updated the test to mirror the original repro more closely by using https://checkip.amazonaws.com/ from the exec step and asserting the proxy-network request summary contains GET https://checkip.amazonaws.com/ -> 200.

@crazy-max
crazy-max requested a review from tonistiigi August 21, 2026 16:04
@crazy-max
crazy-max force-pushed the fix-noop-source-policy-session branch from b62b768 to 879a464 Compare August 21, 2026 16:26
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max
crazy-max force-pushed the fix-noop-source-policy-session branch from 879a464 to bf223fb Compare August 21, 2026 16:26
@tonistiigi
tonistiigi merged commit 8c4b1ca into docker:master Aug 25, 2026
228 of 229 checks passed
@crazy-max
crazy-max deleted the fix-noop-source-policy-session branch August 25, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants