Repository navigation
refuse CR and LF in HttpFetcher request headers - #3438
Open
mrdevel2002-ui wants to merge 1 commit into
Open
mrdevel2002-ui wants to merge 1 commit into
mrdevel2002-ui wants to merge 1 commit into
Conversation
HttpFetcher put per-request and metadata-supplied headers on the outgoing request as given. httpcore folds CR and LF in a header value into spaces but writes the name verbatim, so a header name carrying CRLF injected raw request lines. Check every header name against the RFC 7230 token grammar and every value for control characters before it is added to the request. Generated-by: Claude Code (Claude Fable 5.1)
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.
HttpFetcher adds the headers a request supplies to the outgoing GET as given: the
httpRequestHeadersmap in a per-requesthttp-fetcherblock (a FetchEmitTuple parse context on /pipes and /async,additional_fetch_config_jsonon tika-grpc) and thehttpRequestHeadersmetadata strings. httpcore's BasicLineFormatter folds CR and LF in a header value into spaces but writes the header name verbatim, so a map key such asX\r\nInjected: yes\r\n\r\nPOST /evil HTTP/1.1\r\nHost: hgoes out as raw request lines. The caller gets arbitrary request lines, a body, or a second pipelined request on the fetcher's pooled keep-alive connection, which can desynchronize responses for later tuples. The docs scope per-request config to headers only, so the check belongs in the fetcher:checkHeaderrefuses a name that is not an RFC 7230 token and a value with CR, LF or another control character, on every path that puts a header on the request, before anything is sent.Verified by formatting such a header through httpcore 4.4.16: the name comes out with its CRLF intact, the value with CR and LF replaced by spaces.
testHeadersWithCrLfAreRefusedcovers a per-request name, a per-request value and the metadata string form; it fails on main (nothing thrown, the header reaches the mocked client) and passes here../mvnw clean installof tika-pipes-http (13 tests, checkstyle, spotless, forbidden-apis) is green../mvnw clean install(affected module)Generated-by:per the ASF Generative Tooling Guidancemainbranchtika-bom/pom.xml: not applicable