CVE-2023-33953: Grpcio Excessive Iteration Vulnerability

HIGH
Advisory Identifier: GHSA-496j-2rq6-j6cc
CVSS 7.5
CWE-789 CWE-770
Published
Advisory Summary

CVE-2023-33953 is a HIGH (CVSS 7.5) excessive iteration vulnerability (CWE-789: Memory Allocation with Excessive Size Value) affecting Grpcio libraries in the PyPI ecosystem. The issue involves excessive iteration in grpc. Remediation is available by upgrading affected packages to version 1.53.2, 1.54.3, 1.55.2, 1.56.2.

CVE-2023-33953 at a Glance

CVE Identifier CVE-2023-33953
GHSA Identifier GHSA-496j-2rq6-j6cc
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-789: Memory Allocation with Excessive Size Value
Affected Product Grpcio
Package Ecosystem PyPI
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-2023-33953

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

grpcio fixed: 1.53.2
pip install grpcio>=1.53.2
grpcio fixed: 1.54.3
pip install grpcio>=1.54.3
grpcio fixed: 1.55.2
pip install grpcio>=1.55.2
grpcio fixed: 1.56.2
pip install grpcio>=1.56.2
grpc fixed: 1.53.2
Upgrade grpc to 1.53.2
grpc fixed: 1.54.3
Upgrade grpc to 1.54.3
grpc fixed: 1.55.2
Upgrade grpc to 1.55.2
grpc fixed: 1.56.2
Upgrade grpc to 1.56.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show grpcio

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2023-33953, inspect your installed packages using pip:

pip show grpcio

Analyze the terminal output to locate any version of Grpcio in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.53.2), your application is affected.

Note: The pip show grpcio command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-789: Memory Allocation with Excessive Size Value, where the product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated. In Grpcio, 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

gRPC contains a vulnerability that allows hpack table accounting errors could lead to unwanted disconnects between clients and servers in exceptional cases/ Three vectors were found that allow the following DOS attacks: - Unbounded memory buffering in the HPACK parser - Unbounded CPU consumption in the HPACK parser The unbounded CPU consumption is down to a copy that occurred per-input-block in the parser, and because that could be unbounded due to the memory copy bug we end up with an O(n^2) parsing loop, with n selected by the client. The unbounded memory buffering bugs: - The header size limit check was behind the string reading code, so we needed to first buffer up to a 4 gigabyte string before rejecting it as longer than 8 or 16kb. - HPACK varints have an encoding quirk whereby an infinite number of 0’s can be added at the start of an integer. gRPC’s hpack parser needed to read all of them before concluding a parse. - gRPC’s metadata overflow check was performed per frame, so that the following sequence of frames could cause infinite buffering: HEADERS: containing a: 1 CONTINUATION: containing a: 2 CONTINUATION: containing a: 3 etc…

CVE-2023-33953 Affected Grpcio Versions

8 component(s)
Fixed Versions:
1.53.21.54.31.55.21.56.2
Product / Package Ecosystem Affected Versions Fixed Version
grpcio
PyPI
< 1.53.2
1.53.2
grpcio
PyPI
≥ 1.54.0
< 1.54.3
1.54.3
grpcio
PyPI
≥ 1.55.0
< 1.55.2
1.55.2
grpcio
PyPI
≥ 1.56.0
< 1.56.2
1.56.2
grpc
RubyGems
< 1.53.2
1.53.2
grpc
RubyGems
≥ 1.54.0
< 1.54.3
1.54.3
grpc
RubyGems
≥ 1.55.0
< 1.55.2
1.55.2
grpc
RubyGems
≥ 1.56.0
< 1.56.2
1.56.2

References

Frequently Asked Questions

What is CVE-2023-33953?
CVE-2023-33953 is a security vulnerability in Grpcio involving Excessive Iteration in gRPC under CWE-789: Memory Allocation with Excessive Size Value.
Which Grpcio versions are affected?
Affected versions include releases prior to 1.53.2, 1.54.3, 1.55.2, 1.56.2 across affected packages: grpcio, grpc.
What version fixes CVE-2023-33953?
Upgrading to 1.53.2, 1.54.3, 1.55.2, 1.56.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is grpcio affected?
Yes, grpcio is affected in releases prior to 1.53.2, 1.54.3, 1.55.2, 1.56.2. Upgrade your dependency to 1.53.2, 1.54.3, 1.55.2, 1.56.2 or later.
Is grpc affected?
Yes, grpc is affected in releases prior to 1.53.2, 1.54.3, 1.55.2, 1.56.2. Upgrade your dependency to 1.53.2, 1.54.3, 1.55.2, 1.56.2 or later.
What is the CVSS score of CVE-2023-33953?
CVE-2023-33953 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-2023-33953?
CVE-2023-33953 is classified under CWE-789: Memory Allocation with Excessive Size Value (The product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated.).
How can I check PyPI dependencies for CVE-2023-33953?
Run the dependency tree command: 'pip show grpcio'. 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-496j-2rq6-j6cc",
  "modified" : "2024-07-30T21:37:50Z",
  "published" : "2023-08-09T15:30:15Z",
  "aliases" : [ "CVE-2023-33953" ],
  "summary" : "Excessive Iteration in gRPC",
  "details" : "gRPC contains a vulnerability that allows hpack table accounting errors could lead to unwanted disconnects between clients and servers in exceptional cases/ Three vectors were found that allow the following DOS attacks:\n\n- Unbounded memory buffering in the HPACK parser\n- Unbounded CPU consumption in the HPACK parser\n\nThe unbounded CPU consumption is down to a copy that occurred per-input-block in the parser, and because that could be unbounded due to the memory copy bug we end up with an O(n^2) parsing loop, with n selected by the client.\n\nThe unbounded memory buffering bugs:\n\n- The header size limit check was behind the string reading code, so we needed to first buffer up to a 4 gigabyte string before rejecting it as longer than 8 or 16kb.\n- HPACK varints have an encoding quirk whereby an infinite number of 0’s can be added at the start of an integer. gRPC’s hpack parser needed to read all of them before concluding a parse.\n- gRPC’s metadata overflow check was performed per frame, so that the following sequence of frames could cause infinite buffering: HEADERS: containing a: 1 CONTINUATION: containing a: 2 CONTINUATION: containing a: 3 etc…",
  "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" : "PyPI",
      "name" : "grpcio"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.53.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "grpcio"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.54.0"
      }, {
        "fixed" : "1.54.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "grpcio"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.55.0"
      }, {
        "fixed" : "1.55.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "grpcio"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.56.0"
      }, {
        "fixed" : "1.56.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "grpc"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.53.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "grpc"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.54.0"
      }, {
        "fixed" : "1.54.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "grpc"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.55.0"
      }, {
        "fixed" : "1.55.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "grpc"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.56.0"
      }, {
        "fixed" : "1.56.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-33953"
  }, {
    "type" : "WEB",
    "url" : "https://cloud.google.com/support/bulletins#gcp-2023-022"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-496j-2rq6-j6cc"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/grpc/CVE-2023-33953.yml"
  }, {
    "type" : "WEB",
    "url" : "https://security.snyk.io/vuln/SNYK-RUBY-GRPC-5834442"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-770", "CWE-789" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-07-30T10:26:43Z",
    "nvd_published_at" : "2023-08-09T13:15:09Z"
  }
}