-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP parser accepts an alternative grammar for chunk size in Transfer-Encoding: chunked requests #115
Comments
Yes... I believe that this is only half an issue... Yes, I should have tested for negative values 🙈😅 But I can't shake the feeling that it's good to be lenient - especially where network parsers are concerned. To many client softwares have issues with this and I think there is a distinct possibility of a Hex number starting with |
P.S... there's a possible fix for the issues. Please, if you have the time, let me know what you think. Cheers, |
Hi,
This is a good read explaining why that might not be a great idea. I think your intuition is correct by being liberal in what you accept, however that does not apply to a stack of multiple components - each understanding the request differently - and may indeed lead to a host of security issues, as hinted upon by the several issues I reported. I'm afraid that with multiple components handling the request, there will never be perfect alignment in how they understand it, at least not for HTTP/1.1. But you should stick to the RFC as close as possible to minimize chances of that happening. I see two ways to resolve this:
Regards, David |
System Information
Description
RFC7230§4.1 prescribes the following grammar for chunks:
It seems that due to a reuse of some existing hex-number parsing logic, much more is accepted as chunk size, e.g.
-0x1
, whereas the size should be a plain sequence of hex digits.Rack App to Reproduce
Testing code
This sends the following two requests:
Expected behavior
As the first request does not conform to the grammar for chunked requests, it should be discarded. I believe client connection should also be closed, to ensure that the misaligned parser operating on the rest of the stream does not accidentally produce any new messages.
Actual behavior
The two requests are both accepted and the output of the command above is:
The text was updated successfully, but these errors were encountered: