Repository navigation
Docker: challenge a request without credentials for an image a selector hides, so containerd and Kubernetes pulls send theirs - #808
Merged
Conversation
…or hides Since #703, an image a content selector hides from a caller who may read the repository answers 404 NAME_UNKNOWN, ahead of the arm that challenges an unauthenticated caller. So a request that sent no credential of its own (anonymous under anonymous mode `all`, or an account a trusted-header realm names) got 404 and no WWW-Authenticate. containerd, and with it a Kubernetes pull with an imagePullSecret, sends its credentials only after a 401: the pull failed with "not found" where 2.1 challenged it and the credentials pulled the image. `refusal` now answers a hidden image with the Bearer challenge when the request presented no credential and no registry token. A request with a registry token, an anonymous one included, still finds no such image, as #703 intends. #703's changelog fragment and docs/docker.md say so. Fixes #787 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJc1H3748D8sheqhKTV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #787
Problem
#703 (#704) made a selector-hidden image return 404
NAME_UNKNOWN. That arm now runs before the one that challenges an unauthenticated caller. A request that sent no credential of its own got 404 with noWWW-Authenticate:all, where the anonymous role's grant has a selector;containerd sends its credentials only after a 401. So a Kubernetes pull with an imagePullSecret failed with "not found" for an image the secret may pull. On 2.1 the same request got the challenge, and the pull worked.
Change
Registry::refusal(crates/server/src/images/dispatch.rs) answersDecision::Hiddenwith the Bearer challenge when the request presented neither a credential nor a registry token:!mutation_credential(principal) && claims.is_none().Every other case answers 404
NAME_UNKNOWN, as #703 intends:Pushes and deletes are unchanged (403).
#703's changelog fragment (unreleased) said an anonymous caller now gets 404 too. It, and
docs/docker.md, now describe the challenge. The regression never shipped, so this change adds no fragment of its own.Tests
a_hidden_image_challenges_a_request_without_credentials(crates/server/tests/registry.rs) checks:secret/app, on GET and HEAD, for an anonymous request and for a trusted-header account, whose selector showspublic/*;public/appis still served to both;NAME_UNKNOWNwith an anonymous registry token;Without the fix the test fails with
anonymous: GET of a hidden image, left: 404, right: 401.Run locally:
cargo test -p forge-server --test registry --test trusted_header: 49 + 11 passed;cargo clippy -p forge-server --all-targets -- -D warnings,cargo fmt --all --checkandcargo xtask changelog --check: clean.Generated by Claude Code