CVE-2021-32714: Hyper Integer Overflow Vulnerability

MODERATE
Advisory Identifier: GHSA-5h46-h7hh-c6x9
CVSS 5.9
CWE-190
Published
Advisory Summary

CVE-2021-32714 is a MODERATE (CVSS 5.9) integer overflow vulnerability (CWE-190: Integer Overflow or Wraparound) affecting Hyper libraries in the crates.io ecosystem. The issue involves integer overflow in chunked transfer-encoding. Remediation is available by upgrading affected packages to version 0.14.10.

CVE-2021-32714 at a Glance

CVE Identifier CVE-2021-32714
GHSA Identifier GHSA-5h46-h7hh-c6x9
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-190: Integer Overflow or Wraparound
Affected Product Hyper
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 5.9

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:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2021-32714

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.

hyper fixed: 0.14.10
Upgrade hyper to 0.14.10
Verify Direct and Transitive Dependencies

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-32714, 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-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. 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

### Summary hyper's HTTP server and client code had a flaw that could trigger an integer overflow when decoding chunk sizes that are too big. This allows possible data loss, or if combined with an upstream HTTP proxy that allows chunk sizes larger than hyper does, can result in "request smuggling" or "desync attacks". ### Vulnerability Example: ``` GET / HTTP/1.1 Host: example.com Transfer-Encoding: chunked f0000000000000003 abc 0 ``` hyper only reads the rightmost 64-bit integer as the chunk size. So it reads `f0000000000000003` as `3`. A loss of data can occur since hyper would then read only 3 bytes of the body. Additionally, an HTTP request smuggling vulnerability would occur if using a proxy which instead has prefix truncation in the chunk size, or that understands larger than 64-bit chunk sizes. Read more about desync attacks: https://portswigger.net/research/http-desync-attacks-request-smuggling-reborn ### Impact To determine if vulnerable to _data loss_, these things must be true: - **Using HTTP/1.1.** Since HTTP/2 does not use chunked encoding, it is not vulnerable. - **Using hyper as a server or client.** The body would be improperly truncated in either case. - **Users send requests or responses with chunk sizes greater than 18 exabytes**. To determine if vulnerable to _desync attacks_, these things must be true: - **Using an upstream proxy that allows chunks sizes larger than 64-bit.** If the proxy rejects chunk sizes that are too large, that request won't be forwarded to hyper. ### Patches We have released the following patch versions: - v0.14.10 (to be released when this advisory is published) ### Workarounds Besides upgrading hyper, you can take the following options: - Reject requests manually that contain a `Transfer-Encoding` header. - Ensure any upstream proxy rejects `Transfer-Encoding` chunk sizes greater than what fits in 64-bit unsigned integers. ### Credits This issue was initially reported by [Mattias Grenfeldt](https://grenfeldt.dev/) and Asta Olofsson.

CVE-2021-32714 Affected Hyper Versions

1 component(s)
Fixed Versions:
0.14.10
Product / Package Ecosystem Affected Versions Fixed Version
hyper
crates.io
< 0.14.10
0.14.10

References

Frequently Asked Questions

What is CVE-2021-32714?
CVE-2021-32714 is a security vulnerability in Hyper involving Integer Overflow in Chunked Transfer-Encoding under CWE-190: Integer Overflow or Wraparound.
Which Hyper versions are affected?
Affected versions include releases prior to 0.14.10 across affected packages: hyper.
What version fixes CVE-2021-32714?
Upgrading to 0.14.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is hyper affected?
Yes, hyper is affected in releases prior to 0.14.10. Upgrade your dependency to 0.14.10 or later.
What is the CVSS score of CVE-2021-32714?
CVE-2021-32714 has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-32714?
CVE-2021-32714 is classified under CWE-190: Integer Overflow or Wraparound (The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.).
How can I check crates.io dependencies for CVE-2021-32714?
Run the dependency tree command: 'inspect dependencies for hyper'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-5h46-h7hh-c6x9",
  "modified" : "2021-09-07T21:47:36Z",
  "published" : "2021-07-12T16:55:37Z",
  "aliases" : [ "CVE-2021-32714" ],
  "summary" : "Integer Overflow in Chunked Transfer-Encoding",
  "details" : "### Summary\n\nhyper's HTTP server and client code had a flaw that could trigger an integer overflow when decoding chunk sizes that are too big. This allows possible data loss, or if combined with an upstream HTTP proxy that allows chunk sizes larger than hyper does, can result in \"request smuggling\" or \"desync attacks\".\n\n### Vulnerability\n\nExample:\n\n```\nGET / HTTP/1.1\nHost: example.com\nTransfer-Encoding: chunked\n\nf0000000000000003\nabc\n0\n\n```\n\nhyper only reads the rightmost 64-bit integer as the chunk size. So it reads `f0000000000000003` as `3`. A loss of data can occur since hyper would then read only 3 bytes of the body. Additionally, an HTTP request smuggling vulnerability would occur if using a proxy which instead has prefix truncation in the chunk size, or that understands larger than 64-bit chunk sizes.\n\nRead more about desync attacks: https://portswigger.net/research/http-desync-attacks-request-smuggling-reborn\n\n### Impact\n\nTo determine if vulnerable to _data loss_, these things must be true:\n\n- **Using HTTP/1.1.** Since HTTP/2 does not use chunked encoding, it is not vulnerable.\n- **Using hyper as a server or client.** The body would be improperly truncated in either case.\n- **Users send requests or responses with chunk sizes greater than 18 exabytes**.\n\nTo determine if vulnerable to _desync attacks_, these things must be true:\n\n- **Using an upstream proxy that allows chunks sizes larger than 64-bit.** If the proxy rejects chunk sizes that are too large, that request won't be forwarded to hyper.\n\n### Patches\n\nWe have released the following patch versions:\n\n - v0.14.10 (to be released when this advisory is published)\n\n### Workarounds\n\nBesides upgrading hyper, you can take the following options:\n\n- Reject requests manually that contain a `Transfer-Encoding` header.\n- Ensure any upstream proxy rejects `Transfer-Encoding` chunk sizes greater than what fits in 64-bit unsigned integers.\n\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:N/S:U/C:N/I:N/A:H"
  } ],
  "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-5h46-h7hh-c6x9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32714"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/hyperium/hyper"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2021-0079.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-190" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-07-07T20:05:15Z",
    "nvd_published_at" : "2021-07-07T20:15:00Z"
  }
}