Skip to content

Harden container registry authentication redirects - #57092

Merged
mthalman merged 1 commit into
dotnet:mainfrom
mthalman:dev/mthalman/secure-container-auth-redirects
Nov 13, 2026
Merged

mthalman merged 1 commit into
dotnet:mainfrom
mthalman:dev/mthalman/secure-container-auth-redirects

Conversation

@mthalman

Copy link
Copy Markdown
Member

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.

@mthalman
mthalman requested review from a team and lbussell as code owners November 12, 2026 19:21
Copilot AI balanced review requested due to automatic review settings November 12, 2026 19:21
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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

@mthalman
mthalman merged commit e651252 into dotnet:main Nov 13, 2026
25 of 27 checks passed
@mthalman
mthalman deleted the dev/mthalman/secure-container-auth-redirects branch November 13, 2026 14:35
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 14, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — c6927fb4 Deployed Nov 13, 2026 by mthalman via conclusion #13700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants