Skip to content

Reject invalid HTTP header names - #892

Open
Aschenbath wants to merge 1 commit into
cherrypy:mainfrom
Aschenbath:fix/reject-invalid-header-names-714-721
Open

Aschenbath wants to merge 1 commit into
cherrypy:mainfrom
Aschenbath:fix/reject-invalid-header-names-714-721

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?

Validate the original HTTP field name against the nonempty token grammar before normalizing it. This rejects empty names and whitespace before a colon, including Content-Length : 0, with 400 Bad Request.

Fourteen real-socket cases cover invalid names, valid punctuation and case-insensitive names. Eleven fail on the original code by returning 200; all fourteen pass after the fix and verify connection closure.

Are there changes in behavior for the user?

Malformed names formerly accepted by Cheroot now receive 400, as required by RFC 9110 §5.1 and RFC 9112 §5.1. Valid names keep their existing normalization.

Is it a substantial burden for the maintainers to support this?

The validation uses the existing parser and standard library without new dependencies.

Local validation used the repository's tox environments on Windows/Python 3.12. The full suite had 213 passes, 11 existing skips, 4 existing expected failures, and 2 TLS client-auth error-text failures. The same TLS failure category reproduced with unmodified server.py; the affected parameter combinations vary between runs. The focused run passed all 14 cases but, as expected for a subset, did not meet the whole-project coverage threshold. All applicable pre-commit hooks passed. Tox's subsequent reporting snippets still fail on unescaped Windows paths in the existing configuration. No checks were disabled or relaxed.

AI assistance: Codex implemented and tested this change locally.

Related issue number

Fixes #714. Fixes #721.

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

HTTP field names must be nonempty tokens. Accepting whitespace before
the colon can make Cheroot interpret message framing differently from
an upstream recipient. Validate the original name before normalization
as required by RFC 9110 section 5.1 and RFC 9112 section 5.1.

cherrypy#714
cherrypy#721

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
  • Many forks in 2 days: 18 repositories forked within 2 days
  • Very high PR volume (daily): 31 PRs within a single 24-hour window, 2 of them to repos it can push to
  • High PR volume (weekly): 77 PRs within a single 7-day window, 10 of them to repos it can push to
  • Fork branch then PR within seconds: 31 fork branches followed by upstream PRs within 89s, out of 46 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 #36039451 | 📁 Comparing 525266e 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.07%. Comparing base (e652c2a) to head (525266e).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #892      +/-   ##
==========================================
- Coverage   76.11%   76.07%   -0.05%     
==========================================
  Files          41       42       +1     
  Lines        4932     4957      +25     
  Branches      561      562       +1     
==========================================
+ Hits         3754     3771      +17     
- Misses       1040     1046       +6     
- Partials      138      140       +2     

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 allows empty HTTP header names Cheroot incorrectly allows whitespace after header names

1 participant