Repository navigation
Reject invalid HTTP header names - #892
Open
Aschenbath wants to merge 1 commit into
Open
Aschenbath wants to merge 1 commit into
Aschenbath wants to merge 1 commit into
Conversation
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
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 #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
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?
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, with400 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.
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