-
Notifications
You must be signed in to change notification settings - Fork 62
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
Tiny maybe-bug in obsolete line folding handling #59
Comments
A somewhat related wget bug: https://git.savannah.gnu.org/cgit/wget.git/commit/?id=1fc9c95ec144499e69dc8ec76dbe07799d7d82cd |
Fortunately, that wget bug is very different in practice: if I'm reading this right they were interpreting the header as |
Right! I just thought it was an interesting client-side header-parsing security bug, but maybe this issue was not the right place to say that. |
Oh, sure, it's a good reminder of how big problems can arise from small parsing in obscure things like the handling of whitespace in obsolete line folding :-). I think h11 is pretty careful about these and that the specific issue discussed in this bug is not security relevant, but some day I'm sure I'll be wrong so it's good to check :-) |
The obsolete RFC 2616 says:
Which seems consistent with urllib3's interpretation. Though it also seems to bless h11's interpretation. |
I was looking at urllib3/urllib3#1318, and realized I wasn't quite sure what the right rules were for handling whitespace in headers using the "obsolete line-folding rule". Specifically, if we have a header like
Name: value1${WHITESPACE1}\r\n${WHITESPACE2}value2
then what is the header's logical value?Currently h11 treats it as:
value1${WHITESPACE1} value2
That PR makes urllib3 treat it as:
value1 value2
RFC 7230 says:
(And then in the text it specifies that
obs-fold
tokens should be replaced by one or moreSP
.)As written, this actually says that
${WHITESPACE1}
being non-empty is an error, and onlyName: value1\r\n${WHITESPACE2}value2
is legal (and it becomesName: value1 value2
). So h11 doesn't quite follow that.The reason h11 doesn't quite follow it though is that the spec's ABNF is buggy – its
field-content
rule is just wrong: https://www.rfc-editor.org/errata/eid4189The suggestion in that errata is:
This matches the urllib3 interpretation, but not the current h11 interpretation.
Of course, the comment on that errata is "this is not right", but OTOH "The [fix] is the best approach for now, and a better fix will be developed", someday, maybe.
So I guess ideally h11 should switch to strip trailing whitespace from header lines that are followed by
obs-fold
lines.This is the opposite of a high-priority bug.
The text was updated successfully, but these errors were encountered: