-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Content-Length with obsolete line folding is accepted with invalid input #456
Comments
I think this should yield Thanks for reporting this! |
There is no test yet, and it was reporting error before the commit 01da95f was introduced. The issue happens because after obsolete line folding is discovered the parser goes back to s_header_value_start. But as new content length states h_content_length_num, h_content_length_ws are not handled there it goes to default case and h_general state. |
Thank you for checking it. Your analysis of the code path is absolutely correct! Did I understand it right, that after 01da95f the bug is no longer reproducible? |
No, vice versa, the bug appears after |
@obatysh would you care to clarify if this error is actually reproducible and you experienced it? |
Nevermind, I can reproduce it now. |
Content-Length with line folding was accepted with invalid input. Treat obsolete line folding as space and continue parsing Fixes: nodejs#456 PR-URL: nodejs#458 Reviewed-By: Ben Noordhuis <[email protected]>
According to https://tools.ietf.org/html/rfc7230#section-3.2.4
requests/responses with obsolete line folding can be rejected or obs-fold can be treated as one or more spaces.
obs-fold = CRLF 1*( SP / HTAB )
Currently any input after an obsolete line folding in Content-Length field would be accepted.
Example request:
"POST / HTTP/1.1\r\n"
"Content-Length: 42\r\n"
" ANY TEXT\r\n" // would be accepted and reported as part of Content-Length header field value
"\r\n"
...
The text was updated successfully, but these errors were encountered: