Skip to content

build: avoid empty source policy sessions - #4028

Open
crazy-max wants to merge 1 commit into
docker:masterfrom
crazy-max:fix-noop-source-policy-session
Open

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

Conversation

@crazy-max

@crazy-maxcrazy-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.

@tonistiigitonistiigi 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-maxforce-pushed the fix-noop-source-policy-session branch from ed838db to 4befbc5CompareAugust 21, 2026 15:56
@crazy-max
crazy-maxforce-pushed the fix-noop-source-policy-session branch from 4befbc5 to b62b768CompareAugust 21, 2026 16:03
@crazy-max

crazy-max commented Aug 21, 2026

Copy link
Copy Markdown
MemberAuthor

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-maxforce-pushed the fix-noop-source-policy-session branch from b62b768 to 879a464CompareAugust 21, 2026 16:26
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max
crazy-maxforce-pushed the fix-noop-source-policy-session branch from 879a464 to bf223fbCompareAugust 21, 2026 16:26
Sign up for freeto 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

@crazy-max@tonistiigi