Repository navigation
Harden container registry authentication redirects - #57092
Merged
mthalman merged 1 commit intoNov 13, 2026
Merged
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The cached-credential eviction path lacks regression coverage for replacing a rejected cached token, reusing its replacement, and preserving a newer credential during concurrent acquisition.
1 open issue
What changed in this PR
This PR hardens .NET SDK container registry authentication by separating authentication-realm redirect policy and credential caching from ordinary registry operations.
Changes:
- Reject authentication-realm redirects while preserving normal registry redirects.
- Make authentication caching handler-local, limit each request to one completed acquisition, and restore credentials on eligible transport retries.
- Add regression tests for redirect safety, cache isolation, origin restrictions, and retry behavior, plus contributor guidance.
| File | Description |
|---|---|
test/Microsoft.NET.Build.Containers.UnitTests/AuthRealmHandlerFactoryTests.cs |
Replace redirect-following tests with redirect-rejection assertions. |
test/Microsoft.NET.Build.Containers.UnitTests/AuthHandshakeMessageHandlerTests.cs |
Add production-transport and authentication-state regression coverage. |
src/Containers/Microsoft.NET.Build.Containers/Registry/DefaultRegistryAPI.cs |
Expose the client factory internally for production-path tests. |
src/Containers/Microsoft.NET.Build.Containers/AuthRealmHandlerFactory.cs |
Remove custom redirect handling from realm requests. |
src/Containers/Microsoft.NET.Build.Containers/AuthHandshakeMessageHandler.cs |
Introduce handler-local caching and bounded authentication recovery. |
src/Containers/AGENTS.md |
Document redirect, origin, retry, and regression-test requirements. |
Review effort: Balanced
lbussell
approved these changes
Nov 12, 2026
mthalman
temporarily deployed
to
copilot-pat-pool
November 13, 2026 14:35 — with
GitHub Actions
Inactive
mthalman
temporarily deployed
to
copilot-pat-pool
November 13, 2026 14:36 — with
GitHub Actions
Inactive
mthalman
temporarily deployed
to
copilot-pat-pool
November 13, 2026 14:36 — with
GitHub Actions
Inactive
mthalman
temporarily deployed
to
copilot-pat-pool
November 13, 2026 14:37 — with
GitHub Actions
Inactive
mthalman
temporarily deployed
to
copilot-pat-pool
November 13, 2026 14:40 — with
GitHub Actions
Inactive
mthalman
temporarily deployed
to
copilot-pat-pool
November 13, 2026 14:41 — with
GitHub Actions
Inactive
mthalman
temporarily deployed
to
copilot-pat-pool
November 13, 2026 14:41 — with
GitHub Actions
Inactive
mthalman
temporarily deployed
to
copilot-pat-pool
November 13, 2026 14:42 — with
GitHub Actions
Inactive
This was referenced Nov 13, 2026
This branch was previously deployed
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.

Problem
Authentication-realm requests currently follow redirects using custom redirect handling. Their redirect policy and authentication cache should be independent of ordinary registry operations.
Description
Disable all redirects for authentication-realm requests while preserving normal registry redirects.
Replace the process-wide authentication cache with handler-local state to isolate clients using different credentials. Bound each request to one completed authentication acquisition, and restore authentication after retryable transport failures.