Skip to content
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

Messaging: 7.1 chunked transfer coding: add a note about the risks of too large chunks #749

Closed
wtarreau opened this issue Feb 7, 2021 · 4 comments · Fixed by #768
Closed

Comments

@wtarreau
Copy link

wtarreau commented Feb 7, 2021

The text says

Note that HTTP/1.1 does not define any means to limit the size of a chunked response such that an intermediary can be assured of buffering the entire response.

I'd want to add:

"Implementations must be careful about accurately parsing large values or rejecting the messages, as failure to accurately represent the advertised value due to overflows or loss of precision may have serious security consequences."

I think it is important to remind, because implementations seem to have progressively shifted towards 64 bit repressentations since 7230, 32-bit ones are still much present, and the risk of desynchronization by advertising more than 4GB is high. By the way, some languages do no provide more than 52 bits of accuracy because they use floats to represent any number... The risk remains low (1 injected byte every 4 PB) but its worth asking to be careful.

@mnot
Copy link
Member

mnot commented Feb 10, 2021

Tweaked proposal:

Note that HTTP/1.1 does not define any means to limit the size of a chunked response such that an intermediary can be assured of buffering the entire response. Additionally, very large chunk sizes may cause overflows or loss of precision if their values are not represented accurately in a receiving implementation. This may have serious security consequences.

@wtarreau
Copy link
Author

WFM, but I'm still a bit concerned by the fact that we don't say what the receiver should do here, and it doesn't decide to receive too large a chunk :-/ Should we explicitly mention "a recipient must reject the message as invalid if it cannot accurately represent a received chunk size ?"

@mnot mnot self-assigned this Feb 10, 2021
mnot added a commit that referenced this issue Feb 11, 2021
@mnot
Copy link
Member

mnot commented Feb 11, 2021

I think if we say something about that, we should align it with the language for Content-Length:

Any Content-Length field value greater than or equal to zero is valid. Since there is no predefined limit to the length of content, a recipient must anticipate potentially large decimal numerals and prevent parsing errors due to integer conversion overflows

@wtarreau
Copy link
Author

OK, but then conversion overflows is not the only issue (storing in a float or double is a huge problem, and nowadays sometimes developers don't know, they store it into a "number"). Probably that we should use the same wording for both and slightly adjust the end to say and prevent parsing errors due to integer conversion overflows or precision loss due to integer representation. We can hardly do more but this needs to be said. Using a float with 24-bit mantissa to represent a content-length is already a problem, but in a chunk, 48 MB are enough to miss 3 bytes and desynchronize on a final chunk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants