hyper
Affected
- introduced
0, fixed0.14.10(semver)
Fixed versions
0.14.10
Fix
- Fixed version
0.14.10cargo update -p hyper --precise 0.14.10
Advisory
Also known as: CVE-2021-32715, RUSTSEC-2021-0078
Lenient Parsing of Content-Length Header When Prefixed with Plus Sign
Summary
hyper's HTTP/1 server code had a flaw that incorrectly parses and accepts requests with a Content-Length header with a prefixed plus sign, when it should have been rejected as illegal. This combined with an upstream HTTP proxy that doesn't parse such Content-Length headers, but forwards them, can result in "request smuggling" or "desync attacks".
Vulnerability
The flaw exists in all prior versions of hyper, if built with `rustc` v1.5.0 or newer.
Example:
GET / HTTP/1.1
Host: example.com
Content-Length: +3
abc
This request gets accepted and hyper reads the body as abc. The request _should_ be rejected, according to RFC 7230, since the ABNF for Content-Length only allows for DIGITs. This is due to using the FromStr implementation for u64 in the standard library. By differing from the spec, it is possible to send requests like these to endpoints that have different HTTP implementations, with different interpretations of the payload semantics, and cause "desync attacks".
In this particular case, an upstream proxy would need to error when parsing the Content-Length, but _not_ reject the request (swallowing its own error), and forwarding the request as-is with the Content-Length still included. _Then_ the upstream proxy and hyper would disagree on the length of the request body. The combination of these factors would be extremely rare.
Read more about desync attacks: https://portswigger.net/research/http-desync-attacks-request-smuggling-reborn
Impact
To determine if vulnerable, all these things must be true:
Content-Length header, *OR* can parse the length with the plus sign, the desync attack cannot succeed.Patches
We have released the following patch versions:
Workarounds
Besides upgrading hyper, you can take the following options:
Content-Length header.Content-Length headers with a plus sign prefix.Credits
This issue was initially reported by Mattias Grenfeldt and Asta Olofsson.
Low Basis: The source's own band: LOW
0, fixed 0.14.10 (semver)0.14.10
0.14.10cargo update -p hyper --precise 0.14.10Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0