Repository navigation
Reject control characters in HTTP header values - #894
Open
Aschenbath wants to merge 1 commit into
Open
Aschenbath wants to merge 1 commit into
Aschenbath wants to merge 1 commit into
Conversation
CR, LF and NUL in field values can be interpreted differently by HTTP recipients. RFC 9110 section 5.5 requires rejecting or replacing them before processing. Checking before whitespace trimming also catches carriage returns at the edges of a value. cherrypy#720 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 #894 +/- ##
==========================================
- 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 |
Member
|
What's your motivation with the contributions in the project? Where did you personally face the behavior you're changing? What are your long term participation plans? Why didn't you attempt participating in earlier contribution efforts that seem to be touching this like #832? |
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 NUL and embedded CR while reading raw header lines, before whitespace trimming can hide them. This applies to ordinary and continuation lines. The existing CRLF check continues to reject bare LF.
Are there changes in behavior for the user?
Requests containing CR, LF or NUL in field values receive
400 Bad Request, as required by RFC 9110 §5.5. Spaces, horizontal tabs and opaque non-ASCII bytes remain accepted.Is it a substantial burden for the maintainers to support this?
The change adds a local validation check without dependencies. Twelve real-socket cases exercise control characters in the middle and at the edges of values, continuation lines and valid inputs. Eight fail before the fix; all twelve pass afterward.
Validation through tox on Windows/Python 3.12: 211 passed, 11 existing skips, 4 existing expected failures, and two TLS client-auth error-text failures. This TLS failure category also occurs with unmodified server.py. All applicable pre-commit hooks passed; existing tox reporting snippets fail afterward on unescaped Windows paths. No checks were relaxed.
AI assistance: Codex implemented and tested this change locally.
Related issue number
Fixes #720.
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