CVE-2021-32715: Hyper Lenient Parsing Of Content-Length Header Vulnerability
LOWCVE-2021-32715 is a LOW (CVSS 3.1) lenient parsing of content-length header vulnerability (CWE-444: Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')) affecting Hyper libraries in the crates.io ecosystem. The issue involves lenient parsing of content-length header when prefixed with plus sign. Remediation is available by upgrading affected packages to version 0.14.10.
CVE-2021-32715 at a Glance
Security Impact
CVSS: 3.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N).
How to Fix CVE-2021-32715
To remediate this vulnerability, upgrade all affected Hyper dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade hyper to 0.14.10
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for hyper
How to Check if You Are Affected
To determine whether your application is affected by CVE-2021-32715, inspect your project dependencies for Hyper:
inspect dependencies for hyper
Analyze the terminal output to locate any version of Hyper in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.14.10), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-444: Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling'), where the product acts as an intermediary http agent (such as a proxy or firewall) in the data flow between two entities such as a client and server, but it does not interpret malformed http requests or responses in ways that are consistent with how the messages will be processed by those entities that are at the ultimate destination. In Hyper, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-32715 Affected Hyper Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
hyper
|
crates.io |
< 0.14.10
|
0.14.10
|
References
Frequently Asked Questions
What is CVE-2021-32715?
Which Hyper versions are affected?
What version fixes CVE-2021-32715?
Is hyper affected?
What is the CVSS score of CVE-2021-32715?
What CWE is associated with CVE-2021-32715?
How can I check crates.io dependencies for CVE-2021-32715?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-f3pg-qwvg-p99c",
"modified" : "2021-09-07T21:49:21Z",
"published" : "2021-07-12T16:54:20Z",
"aliases" : [ "CVE-2021-32715" ],
"summary" : "Lenient Parsing of Content-Length Header When Prefixed with Plus Sign",
"details" : "### Summary\n\nhyper'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\".\n\n### Vulnerability\n\nThe flaw exists in all prior versions of hyper, if built with [`rustc` v1.5.0 or newer](https://github.com/rust-lang/rust/pull/28826/commits/123a83326fb95366e94a3be1a74775df4db97739).\n\nExample:\n\n```\nGET / HTTP/1.1\nHost: example.com\nContent-Length: +3\n\nabc\n```\n\nThis 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 `DIGIT`s. 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\".\n\nIn 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.\n\nRead more about desync attacks: https://portswigger.net/research/http-desync-attacks-request-smuggling-reborn\n\n### Impact\n\nTo determine if vulnerable, all these things must be true:\n\n- **Using hyper as an HTTP server**. While the lenient decoder also exists in the client, a vulnerability does not exist around _responses_.\n- **Using HTTP/1**. The HTTP/2 code uses a stricter parser.\n- **Using a vulnerable HTTP proxy upstream to hyper**. If an upstream proxy correctly rejects the illegal `Content-Length` header, *OR* can parse the length with the plus sign, the desync attack cannot succeed.\n\n### Patches\n\nWe have released the following patch versions:\n\n- v0.14.10 (to be released when this advisor is published)\n\n### Workarounds\n\nBesides upgrading hyper, you can take the following options:\n\n- Reject requests manually that contain a plus sign prefix in the `Content-Length` header.\n- Ensure any upstream proxy handles `Content-Length` headers with a plus sign prefix.\n\n### Credits\nThis issue was initially reported by [Mattias Grenfeldt](https://grenfeldt.dev/) and Asta Olofsson.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "hyper"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.14.10"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/hyperium/hyper/security/advisories/GHSA-f3pg-qwvg-p99c"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32715"
}, {
"type" : "WEB",
"url" : "https://github.com/rust-lang/rust/pull/28826/commits/123a83326fb95366e94a3be1a74775df4db97739"
}, {
"type" : "WEB",
"url" : "https://github.com/hyperium/hyper/commit/1fb719e0b61a4f3d911562a436a2ff05fd7cb759"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/hyperium/hyper"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2021-0078.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-444" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2021-07-07T20:08:46Z",
"nvd_published_at" : "2021-07-07T20:15:00Z"
}
}