Skip to content

Reject duplicate Content-Length fields - #895

Open
Aschenbath wants to merge 1 commit into
cherrypy:mainfrom
Aschenbath:fix/reject-duplicate-content-length-737
Open

Aschenbath wants to merge 1 commit into
cherrypy:mainfrom
Aschenbath:fix/reject-duplicate-content-length-737

Conversation

@Aschenbath

Copy link
Copy Markdown

What kind of change does this PR introduce?

  • 🐞 bug fix
  • 🐣 feature
  • 📋 docs update
  • 📋 tests/coverage improvement
  • 📋 refactoring
  • 💥 other

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.

  • I wrote descriptive pull request text above
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences
  • I think the code is well written
  • Unit tests for the changes exist
  • Integration tests for the changes exist (if applicable)
  • I used the same coding conventions as the rest of the project
  • The new code doesn't generate linter offenses
  • Project documentation (in docs/) and inline docstrings reflect the changes
  • My commits each have a descriptive title and a body explaining the why
    (see good commit messages)
  • I have added a change log entry
    (can be done once the PR number is known; alternatively, you can
    use a related issue number if one exists)
  • I'm planning to squash related commits together before final merge
  • I have read the contribution guide and the
    code of conduct

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
@agentscanapp

agentscanapp Bot commented Nov 20, 2026

Copy link
Copy Markdown

Automation signals

Activity patterns show signs of automation.

View full analysis →

Evidence
  • Fork spike: 18 forks within 24 hours
  • PRs to many projects in one day: Opened PRs in 20 different repos within 24 hours
  • High PR volume (weekly): 87 PRs within a single 7-day window, 10 of them to repos it can push to
  • Very high PR volume (daily): 36 PRs within a single 24-hour window
  • Fork branch then PR within seconds: 30 fork branches followed by upstream PRs within 89s, out of 43 branches created in total

Last 5 PRs:

This is an automated analysis by AgentScan

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided A mark meaning that a new change log entry is present within the patch. label Nov 20, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cheroot | 🛠️ Build #36039727 | 📁 Comparing c8c62f4 against latest (e652c2a)

  🔍 Preview build  

5 files changed · + 1 added · ± 4 modified

+ Added

± Modified

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.11%. Comparing base (e652c2a) to head (c8c62f4).
✅ All tests successful. No failed tests found.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentscan:automation-signals bot:chronographer:provided A mark meaning that a new change log entry is present within the patch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cheroot is vulnerable to request smuggling via multiple Content-Length headers

1 participant