CVE-2021-32715
JSON

3.1low

Lenient Parsing of Content-Length Header When Prefixed with Plus Sign

Severity
3.1low CVSS:3.1 by GitHub_M
Exploit likelihood
1.13% (higher than 67% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-f3pg-qwvg-p99cRUSTSEC-2021-0078

Description

hyper is an HTTP library for rust. 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". The flaw exists in all prior versions of hyper prior to 0.14.10, if built with `rustc` v1.5.0 or newer. The vulnerability is patched in hyper version 0.14.10. Two workarounds exist: One may reject requests manually that contain a plus sign prefix in the `Content-Length` header or ensure any upstream proxy handles `Content-Length` headers with a plus sign prefix.

Affected

Product or packageVersionsReported by
hyperium hyper< 0.14.10CVE List
hyper (crates.io)before 0.14.10, from 0.0.0-0 before 0.14.10GitHub Advisory Database, RustSec Advisory Database
hyper hyperbefore 0.14.10NVD

All scores

GitHub_M3.1low CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N
GitHub3.1low CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N
RustSec Advisory Database5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
NVD5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
NVD4.3medium CVSS:2.0AV:N/AC:M/Au:N/C:N/I:P/A:N

Classification

What each source says

CVE List

hyper is an HTTP library for rust. 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". The flaw exists in all prior versions of hyper prior to 0.14.10, if built with `rustc` v1.5.0 or newer. The vulnerability is patched in hyper version 0.14.10. Two workarounds exist: One may reject requests manually that contain a plus sign prefix in the `Content-Length` header or ensure any upstream proxy handles `Content-Length` headers with a plus sign prefix.

GitHub Advisory Database
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:

  • Using hyper as an HTTP server. While the lenient decoder also exists in the client, a vulnerability does not exist around responses.
  • Using HTTP/1. The HTTP/2 code uses a stricter parser.
  • 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.
Patches

We have released the following patch versions:

  • v0.14.10 (to be released when this advisor is published)
Workarounds

Besides upgrading hyper, you can take the following options:

  • Reject requests manually that contain a plus sign prefix in the Content-Length header.
  • Ensure any upstream proxy handles Content-Length headers with a plus sign prefix.
Credits

This issue was initially reported by Mattias Grenfeldt and Asta Olofsson.

RustSec Advisory Database

hyper's HTTP header parser accepted, according to RFC 7230, illegal contents inside Content-Length headers. Due to this, upstream HTTP proxies that ignore the header may still forward them along if it chooses to ignore the error.

To be vulnerable, hyper must be used as an HTTP/1 server and using an HTTP proxy upstream that ignores the header's contents but still forwards it. Due to all the factors that must line up, an attack exploiting this vulnerability is unlikely.

NVD (es)

El código del servidor HTTP/1 de hyper presentaba un fallo que analizaba y aceptaba incorrectamente peticiones con una cabecera "Content-Length" con un signo más prefijado, cuando debería haber sido rechazada como ilegal. Esto, combinado con un proxy HTTP ascendente que no analiza dichas cabeceras "Content-Length", sino que las reenvía, puede resultar en "request smuggling" o "desync attacks". El fallo se presenta en todas las versiones de hyper anteriores a 0.14.10, si se construye con "rustc" versión v1.5.0 o más reciente. La vulnerabilidad está parcheada en la versión 0.14.10 de hyper. Se presentan dos soluciones: Uno puede rechazar manualmente las peticiones que contengan un prefijo de signo más en la cabecera "Content-Length" o asegurarse de que cualquier proxy upstream maneja las cabeceras "Content-Length" con un prefijo de signo más

References

Sources

SourceRecordLicence
CVE ListCVE-2021-32715 changed 2024-08-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-f3pg-qwvg-p99c changed 2026-09-10CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2021-0078 changed 2026-10-12CC0-1.0
NVDCVE-2021-32715 changed 2026-06-17Public domain