Repository navigation
fix(reqs): reject malformed chunked Transfer-Encoding tokens - #650
code1a2024 wants to merge 1 commit into
Conversation
|
agent's review says this:
|
|
Thank you for the review. You are correct on all points. I re-traced the function and confirmed:
What this patch actually catches is malformed tokens where the "chunked" substring is present but the token is not properly separated from the next one — e.g. I have updated the PR title, description, and the linked issue to remove the smuggling claim. |
check_chunked_and_sanitize_transfer_encoding() returns 0 (benign) when the substring "chunked" is detected but the token is not a properly delimited final coding — e.g., "chunkedx" or "chunkedgzip". In these cases, strncasecmp() matches "chunked" as a substring, but the final-position validation fails (chunked[7] is neither NUL nor ';'), and the function silently returns 0 — inconsistent: the substring was recognized but the malformation was ignored. This is a protocol conformance hardening, not a smuggling fix. Valid RFC 7230 inputs like "gzip, chunked" and "chunked, gzip" are handled correctly by the existing code and are not affected. Fix: add a guard after the final-position check: when chunked != NULL but the validation failed, return -1 to trigger the existing 400 Bad Request path in process_client_headers(). Assisted-by: Qwen-Coder <qwen-coder@alibabacloud.com> Signed-off-by: litenglong <litenglong@kylinos.cn>
7f4d1f2 to
292882c
Compare
would you mind quoting the section describing this behaviour? |
|
After further analysis, I agree this patch is unnecessary.
The two affected inputs ( |
Fixes: #649
check_chunked_and_sanitize_transfer_encoding()returns 0 (benign) whenthe substring "chunked" is detected but the token is not a properly
delimited final coding — e.g.,
chunkedxorchunkedgzip. Thesemalformed inputs pass the
strncasecmpmatch but fail the final-positionvalidation (
chunked[7]is neither NUL nor;), yet the functionsilently returns 0 rather than signaling an error.
Fix: Add a guard after the final-position check: when
chunked != NULLbut the validation failed, return -1 to trigger the existing 400 Bad
Request path in
process_client_headers().Changes: 1 file,
src/reqs.c+2 lines.