Repository navigation
Reject duplicate Content-Length fields - #895
Open
Aschenbath wants to merge 1 commit into
Open
Aschenbath wants to merge 1 commit into
Aschenbath wants to merge 1 commit into
Conversation
Using the last of several Content-Length fields can disagree with an upstream HTTP recipient and leave a different request boundary. Reject duplicates before dispatch, including differently cased field names. RFC 9112 section 6.3 permits rejecting identical duplicate values too. cherrypy#737 Assisted-by: LLM
Automation signalsActivity patterns show signs of automation. Evidence
Last 5 PRs: This is an automated analysis by AgentScan |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #895 +/- ##
==========================================
- Coverage 76.11% 76.11% -0.01%
==========================================
Files 41 42 +1
Lines 4932 4957 +25
Branches 561 562 +1
==========================================
+ Hits 3754 3773 +19
- Misses 1040 1045 +5
- Partials 138 139 +1 |
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.
What kind of change does this PR introduce?
What do these changes do?
Reject a second Content-Length field before it can overwrite the first. Field-name normalization makes the check case-insensitive. A 400 response closes the connection before the application or a pipelined request can use the ambiguous framing.
Are there changes in behavior for the user?
Duplicate Content-Length fields now receive
400 Bad Request, including duplicates with equal values. This uses the rejection option allowed by RFC 9112 §6.3. Single length fields continue to work.Is it a substantial burden for the maintainers to support this?
The check uses the existing header dictionary. Six real-socket cases cover both conflicting orders, identical values, mixed casing and a valid single field; each verifies that the connection closes before the pipelined request. Five cases fail before the fix; all six pass afterward.
Validation through tox on Windows/Python 3.12: 205 passed, 11 existing skips, 4 existing expected failures, and two TLS client-auth error-text failures from a category also reproduced on unmodified code. An initial overlapping tooling run hit a coverage database error; running the tools separately resolved it. All applicable pre-commit hooks passed; existing tox reporting snippets still fail on unescaped Windows paths. No checks were relaxed.
AI assistance: Codex implemented and tested this change locally.
Related issue number
Fixes #737.
Checklist
Tip
New to open source contributions? Making a lovely PR is a great read.
and description in grammatically correct, complete sentences
docs/) and inline docstrings reflect the changes(see good commit messages)
(can be done once the PR number is known; alternatively, you can
use a related issue number if one exists)
code of conduct