Skip to content

fix: bind credentials to origin and reject TLS downgrade redirects - #2085

Merged
cstamas merged 2 commits into
masterfrom
security/credential-leak-tls-downgrade
Aug 31, 2026
Merged

fix: bind credentials to origin and reject TLS downgrade redirects#2085
cstamas merged 2 commits into
masterfrom
security/credential-leak-tls-downgrade

Conversation

@gnodet

@gnodet gnodet commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes 5 findings from the maven-resolver security audit (scan-maven-resolver-20260811):

Finding Severity Description
f002 MEDIUM Settings credentials attached by bare ID to POM-declared repositories
f008 MEDIUM Apache transport silently follows https-to-http downgrade redirects
f009 MEDIUM JDK transport Authenticator hands credentials to any challenging host
f016 MEDIUM Jetty transport follows https-to-http redirects without a downgrade guard
f027 LOW Operator-configured static auth headers follow redirects cross-origin

Root cause: Credential release decisions ignore where the request is actually going: selectors match on bare repository id with no host binding, authenticators answer any challenger, redirect handling follows cross-origin and https-to-http hops.

Fix: Enforce one rule across all transports: credentials go only to the configured origin, and https never silently becomes http.

Test plan

  • Existing tests pass
  • Credential scoping validated per transport
  • TLS downgrade rejection tested

🤖 Generated with Claude Code

@gnodet
gnodet force-pushed the security/credential-leak-tls-downgrade branch 5 times, most recently from 6e4ce3b to 8564ef1 Compare August 31, 2026 02:06
@gnodet
gnodet marked this pull request as ready for review August 31, 2026 05:20
@gnodet
gnodet requested a review from cstamas August 31, 2026 05:20
@gnodet gnodet added bug Something isn't working priority:critical Crashes, loss of data, severe memory leak labels Aug 31, 2026
@gnodet gnodet added this to the 2.0.23 milestone Aug 31, 2026
@cstamas

cstamas commented Aug 31, 2026

Copy link
Copy Markdown
Member

LGTM, and a Q: URL transport does not need any change?

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Excellent security hardening across all three HTTP transports with comprehensive test coverage. The credential binding and TLS downgrade rejection are correctly implemented.

⚠️ @since tag corrections (12 locations)

All 12 @since tags across the PR say 2.0.22, but that version is already released (tag exists). They must be updated to @since 2.0.23 to match the milestone. Affected files:

  • RemoteRepositoryManager.java (1)
  • DefaultRemoteRepositoryManager.java (1)
  • ApacheTransporterConfigurationKeys.java (2)
  • OriginScopedHeadersInterceptor.java (1)
  • ResolverRedirectStrategy.java (1)
  • JdkTransporterConfigurationKeys.java (2)
  • JettyTransporterConfigurationKeys.java (2)
  • InsecureRedirectGuard.java (1)
  • OriginScopedHeadersListener.java (1)

Minor observations (not blocking)

  • JDK transport redirect error quality: When followableRedirect() returns null on HTTPS→HTTP downgrade, the raw 302 is returned, producing a generic HttpTransporterException(302). Apache's equivalent throws ProtocolException with an explicit message naming the config property. Consider matching the error quality for parity.
  • effectivePort duplication: 5 near-identical implementations across modules. Cross-module dedup is constrained by different HTTP APIs, but within-module consolidation (Apache: 2 copies, JDK: 2 copies) is feasible.

Positive observations

  • Credential scoping by scheme+host+port is correct across all transports
  • Fail-closed on unknown target host
  • Case-insensitive hostname and header comparisons
  • Default port normalization prevents port-mismatch bypasses
  • Descriptor-repository credential blocking correctly allows mirrored repos

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

@gnodet

gnodet commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

@cstamas — good question. The URL transport (UrlTransporter) already has both guards built in:

  1. TLS downgrade rejection (line 358–363): blocks HTTPS → HTTP redirects unless redirectAllowDowngrade is explicitly enabled (false by default)
  2. Credential scoping on redirect (line 349–356): strips auth when the redirect target has a different authority

These were already part of the URL transport's redirect handling prior to this PR. The three transports that needed fixing were:

  • Apache (f008): silently followed https→http downgrades
  • JDK (f009): Authenticator handed credentials to any challenging host
  • Jetty (f016): followed https→http redirects without a downgrade guard

The URL transport was already doing the right thing here.

gnodet and others added 2 commits August 31, 2026 13:13
Add OriginScopedHeadersListener to confine preemptive Authorization
and user-configured HTTP headers to the repository origin so a
cross-origin redirect does not replay them to the target host.
The listener is only registered when there are actual credentials
or configured headers to protect — challenge-based authentication
from Jetty's auth store is already URI-scoped.

Add InsecureRedirectGuard (QueuedListener) to abort any request
whose URI is non-HTTPS when the repository was configured with
HTTPS, preventing TLS-downgrade redirect attacks.

Both guards are registered as client-level request listeners so
they also fire on copied redirect requests created by Jetty's
redirector.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2.0.22 is already released; new API additions must target 2.0.23.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet force-pushed the security/credential-leak-tls-downgrade branch from 134f538 to fe20051 Compare August 31, 2026 11:13
@cstamas
cstamas merged commit 89da727 into master Aug 31, 2026
5 checks passed
@cstamas
cstamas deleted the security/credential-leak-tls-downgrade branch August 31, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority:critical Crashes, loss of data, severe memory leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants