fix: prevent Content-Length smuggling, log format-string injection, and common-pool starvation#3395
Merged
Merged
Conversation
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
…hanges and replacements Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
Co-authored-by: trumpetinc <6618744+trumpetinc@users.noreply.github.com>
…nd common-pool starvation in streaming bodies Signed-off-by: Marvin Froeder <velo.br@gmail.com>
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.
Summary
Security fixes identified during review of the request-body-streaming refactor:
RequestTemplate.java): Restored the defensiveContent-Lengthheader clear before conditionally setting it. The streaming refactor had accidentally removed theheader(CONTENT_LENGTH, Collections.emptyList())reset, allowing duplicate or staleContent-Lengthvalues whenbody()is called more than once or when a prior header already existed.Logger.java): The body-logging call was changed fromlog(configKey, "%s", body.toString())tolog(configKey, body.toString()), making raw request body the printf format string. Any%in the body (e.g. JSON{"discount":"50%"}) throws an uncheckedIllegalFormatExceptionpropagating out oflogRequest. Fixed by restoring"%s"as the format argument.AsyncApacheHttp5Client.java,Http2Client.java): Both async clients defaulted toForkJoinPool.commonPool()as the executor for the blocking body-write bridge. This pins one JVM-wide common-pool thread per in-flight request, defeating the async model and enabling DoS via pool starvation. Replaced with a dedicated daemon-threadnewCachedThreadPool().Test plan
mvn testpasses (778 tests — core: 601, hc5: 102, java11: 75, 0 failures)mvn clean install -Pdev🤖 Generated with Claude Code