fix: stop rejecting request bodies that contain CR or LF - #40
Open
shreemaan-abhishek wants to merge 1 commit into
Open
fix: stop rejecting request bodies that contain CR or LF#40shreemaan-abhishek wants to merge 1 commit into
shreemaan-abhishek wants to merge 1 commit into
Conversation
The body is length-framed: Content-Length is always derived from the body, and a caller-supplied value must match it. A CR or LF inside the body cannot reach the request line or headers, which have their own token and field-value validation. The check only broke legal bodies such as pretty-printed JSON. Fixes #38
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThe request client removes CR/LF rejection for request bodies. The validation test count is updated, and a TCP test verifies verbatim transmission with the expected content length and response. ChangesRequest body validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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.
Fixes #38.
Any request whose body contained a CR or LF was refused with
invalid requestbefore a byte reached the wire, so pretty-printed JSON, multipart and plain text bodies all failed. lua-resty-http sends all of these.The check protected nothing: the body is length-framed (
Content-Lengthis always derived fromreq->body.len, and a caller-supplied value must match it exactly), so a CR or LF inside the body cannot escape into the request line or headers. The method, path, host and header fields keep their own token / vchar / field-value validation, which is where the injection defense actually lives.Changes
req->bodyinngx_http_ffi_client_build_requestand remove the now-unusedngx_http_ffi_client_has_crlfhelper.t/015TEST 10: a body containing both a bare LF and a CRLF is sent verbatim, with the exact wire bytes asserted viatcp_query.Verification
Full Test::Nginx suite passes on the llhttp backend (318 tests), including the new block.
Summary by CodeRabbit
Bug Fixes
Tests