Skip to content

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
GoogleContainerTools:masterfrom
codesbysaravana:fix-realm-credential-leak
Open

codesbysaravana wants to merge 1 commit into
GoogleContainerTools:masterfrom
codesbysaravana:fix-realm-credential-leak

Conversation

@codesbysaravana

Copy link
Copy Markdown

Refs #4523.

Before this change, the realm from a registry's WWW-Authenticate header was used as-is for the initial token request, including when credentials (Basic or OAuth2 refresh token) were configured.

With this change, RegistryAuthenticator sends 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 (so registry-1.docker.io -> auth.docker.io keeps working), or is listed in the new jib.trustedAuthHosts system 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.

This branch has not been deployed

No deployments
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.

2 participants