Repository navigation
fix(core): don't send credentials to an unrelated token server named in the WWW-Authenticate realm - #4536
Open
codesbysaravana wants to merge 1 commit into
Conversation
Dreamweaver156191
approved these changes
Oct 16, 2026
This branch has not been 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.
Refs #4523.
Before this change, the
realmfrom a registry'sWWW-Authenticateheader was used as-is for the initial token request, including when credentials (Basic or OAuth2 refresh token) were configured.With this change,
RegistryAuthenticatorsends credentials in that initial token request only if the realm host is the registry host (port and scheme ignored), shares the registry's registrable domain (soregistry-1.docker.io->auth.docker.iokeeps working), or is listed in the newjib.trustedAuthHostssystem property (comma-separated host names). Otherwise authentication fails before any request is sent, with a message naming the realm host and the property. Anonymous token requests are unchanged.Scope: this change only adds the realm host check described above.
This is a proposal based on the options listed in the issue (registrable-domain match plus an opt-in allowlist). Registries whose token server is on an unrelated domain will need the property. I did not test against real ACR, OpenShift or Nexus registries; I ran the jib-core unit tests only.
Tests: realm trust cases; an untrusted realm never reaches the HTTP client for Basic or refresh-token credentials; anonymous and trusted-realm requests still succeed; a host in the property is accepted.