Repository navigation
keep fetcher credentials on the first host across redirects - #3469
Merged
tballison merged 1 commit intoNov 2, 2026
Merged
Conversation
HttpClient copies the original request's headers onto every redirect and AuthScope.ANY answers a challenge from any host, so a redirect handed a fetcher's JWT or basic password to whichever host it named. Drop Authorization and Cookie once a request has left its first host and leave a challenge from another host unanswered.
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.
HttpClientFactorybuilds the client behindHttpFetcher,AtlassianJwtFetcherand the ES, OpenSearch and Solr plugins. WithmaxRedirectsabove 0, HttpClient'sRedirectExeccopies the original request's headers onto every redirect, and the factory registers configured credentials underAuthScope.ANY. A redirect from a fetched server to another host therefore hands that host the fetcher'sAuthorizationJWT and anyCookieheader outright, and the host can collect the configured basic or NTLM password by answering401withWWW-Authenticate: Basic. The HTTP fetcher's security notes accept that a redirect can reach any host as an SSRF matter, but they don't say the operator's secrets go along, and the redirect target is chosen by the remote server, not by the trusted caller who chose the fetch key. An open redirect on an otherwise trusted host is enough. curl fixed the same problem as CVE-2018-1000007.The fix sits in the factory so every client it builds gets it.
CredentialsHostGuardrecords the first hop's target, removesAuthorizationandCookiefrom any later hop on another host, port or scheme, and leaves a challenge from such a host unanswered. It is a request interceptor becauseRedirectExecrefills a redirect that has no headers from the original request, so removing the last header in a redirect strategy would put the JWT straight back. Two trade-offs are worth a look. Anhttptohttpsupgrade now drops credentials, as it does in curl, so those fetch keys need thehttpsURL. Secrets in customhttpRequestHeadersstill follow redirects, because the client can't tell which headers are secret. Both are in the security notes inhttp.adoc. Same-host redirects behave as before.HttpFetcherRedirectCredentialsTestruns the real fetcher against two loopback servers on different ports. On main the second server gets theBearertoken on both a direct and a two-hop redirect, and its401is answered with the password, so three of the five tests fail. With the patch all five pass; the two same-host tests pass either way. A throwaway test againstAtlassianJwtFetchergave the same result: the first host sawJWT ..., the second nothing../mvnw clean apache-rat:check install -Pciof tika-httpclient-commons, tika-pipes-http, tika-pipes-atlassian-jwt, tika-pipes-es, tika-pipes-opensearch and tika-pipes-solr (tests, checkstyle, spotless, forbidden-apis) is green on JDK 21, and the first three modules are also green on JDK 25../mvnw clean install(affected modules)Generated-by: Claude Code (Claude Opus 5.5), disclosed here rather than as a commit trailermainbranchtika-bom/pom.xml: not applicable