GHSA-rqr8-pxh7-cq3g: Eth abi Denial of Service Vulnerability

MODERATE
CVSS 4.3
CWE-400
Published
Advisory Summary

GHSA-rqr8-pxh7-cq3g is a MODERATE (CVSS 4.3) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Eth abi libraries in the PyPI ecosystem. The issue involves ethereum abi decoder dos when parsing zst. Remediation is available by upgrading affected packages to version 4.2.0.

GHSA-rqr8-pxh7-cq3g at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-rqr8-pxh7-cq3g
Severity MODERATE
CVSS v3.1 Base Score 4.3
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Eth abi
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 4.3

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

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

How to Fix GHSA-rqr8-pxh7-cq3g

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

eth-abi fixed: 4.2.0
pip install eth-abi>=4.2.0
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 eth-abi

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-rqr8-pxh7-cq3g, inspect your installed packages using pip:

pip show eth-abi

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Eth abi, 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

With this notification I would like to inform about a DoS vector in the Ethereum ABI decoder. We have not yet found a way to exploit this with high impact, still the bug could potentially lead to a DoS in server systems. Feel free to ask about an extension of the embargo period. Trail of Bits is informing you and other vendors as a community service, and so we do not seek a bug bounty on these issues. ## BUG DESCRIPTION Parsers must be written in a robust way, which avoids for example unrecoverable crashes, misinterpretation, hangs, or excessive resource consumption. The recent news about the aCropalypse bug also highlights that more subtle bugs like blind spots in file formats can lead to serious implications. Sometimes the specifications are at fault and sometimes the implementations. In the case of the Ethereum ABI, I have to blame the specification more than the vulnerable implementations. The specification allows zero-sized-types (ZST), which can cause denial-of-service upon parsing a malicious payload and schema. If a ZST takes zero bytes when stored on disk, but after parsing occupies memory, then there is the possibility for a denial of service. For instance, what will happen if a parser expects an array of ZST? It will try to parse as many ZST as the byte array claims to contain. The following figure first shows a payload of 20 bytes which will deserialize to an array of the numbers 2, 1, 3. The second payload will deserialize to 232 elements of a ZST like an empty tuple or empty array. 20 bytes of data: ``` length=0x3u64 2u32 1u32 3u32 ``` 8 bytes of data ``` length=0xFFFFFFFu64 ``` Now, this is not a problem if the individual elements take zero memory after parsing. Though, a common flaw is at least during serialization a large amount of memory will be required. If this case is not handled explicitly in the implementation then we are facing a DoS vector. For example, an implementation could decide to represent an array of ZST differently than a normal array and parse it in constant time, instead of looping and naively adding elements to an in-memory array. I mentioned that I believe this is a flaw in the specification. The reason for this is that the Ethereum ABI could have decided to disallow ZST completely. Actually, it turned out that in the latest versions of Solidity and Vyper it is not possible to define ZST like empty tuples or empty arrays. Even though the languages do not allow it, it is still allowed in the ABI specification. ## POC We define the data payload as `0x0000000000000000000000000000000000000000000000000000000000000020 00000000000000000000000000000000000000000000000000000000FFFFFFFF`. It consists of two 32-byte blocks, which describe a serialized array of ZST. The first block defines an offset to the array’s elements. The second block defines the length of the array. Independent of the programming language we will reference it always as payload. We will try to decode this payload using the ABI schemata ()[] and uint32[0][]. The former represents a dynamic array of empty tuples and the latter a dynamic array of empty static arrays. The distinction between dynamic and static is important here, because an empty static array takes zero bytes, whereas a dynamic one takes a few bytes because it serializes the length of the array. The following Python program uses the official eth_abi library and will hang and eventually cause an out-of-memory error. from eth_abi import decode data = bytearray.fromhex(payload) decode(['()[]'], data) ## SUGGESTED REMEDIATION We suggest to disallow the parsing of ZST.

GHSA-rqr8-pxh7-cq3g Affected Eth abi Versions

1 component(s)
Fixed Versions:
4.2.0
Product / Package Ecosystem Affected Versions Fixed Version
eth-abi
PyPI
< 4.2.0
4.2.0

References

Frequently Asked Questions

What is GHSA-rqr8-pxh7-cq3g?
GHSA-rqr8-pxh7-cq3g is a security vulnerability in Eth abi involving Ethereum ABI decoder DoS when parsing ZST under CWE-400: Uncontrolled Resource Consumption.
Which Eth abi versions are affected?
Affected versions include releases prior to 4.2.0 across affected packages: eth-abi.
What version fixes GHSA-rqr8-pxh7-cq3g?
Upgrading to 4.2.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is eth-abi affected?
Yes, eth-abi is affected in releases prior to 4.2.0. Upgrade your dependency to 4.2.0 or later.
What is the CVSS score of GHSA-rqr8-pxh7-cq3g?
GHSA-rqr8-pxh7-cq3g has a CVSS v3.1 base score of 4.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with GHSA-rqr8-pxh7-cq3g?
GHSA-rqr8-pxh7-cq3g is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check PyPI dependencies for GHSA-rqr8-pxh7-cq3g?
Run the dependency tree command: 'pip show eth-abi'. 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-rqr8-pxh7-cq3g",
  "modified" : "2023-11-24T16:54:11Z",
  "published" : "2023-11-24T16:54:11Z",
  "aliases" : [ ],
  "summary" : "Ethereum ABI decoder DoS when parsing ZST",
  "details" : "With this notification I would like to inform about a DoS vector in the Ethereum ABI decoder. \nWe have not yet found a way to exploit this with high impact, still the bug could potentially lead to a DoS in server systems.\n\nFeel free to ask about an extension of the embargo period.\n\nTrail of Bits is informing you and other vendors as a community service, and so we do not seek a bug bounty on these issues.\n\n## BUG DESCRIPTION\n\nParsers must be written in a robust way, which avoids for example unrecoverable crashes, misinterpretation, hangs, or excessive resource consumption. The recent news about the aCropalypse bug also highlights that more subtle bugs like blind spots in file formats can lead to serious implications. Sometimes the specifications are at fault and sometimes the implementations.\n\nIn the case of the Ethereum ABI, I have to blame the specification more than the vulnerable implementations. The specification allows zero-sized-types (ZST), which can cause denial-of-service upon parsing a malicious payload and schema. If a ZST takes zero bytes when stored on disk, but after parsing occupies memory, then there is the possibility for a denial of service.\n\nFor instance, what will happen if a parser expects an array of ZST? It will try to parse as many ZST as the byte array claims to contain. The following figure first shows a payload of 20 bytes which will deserialize to an array of the numbers 2, 1, 3. The second payload will deserialize to 232 elements of a ZST like an empty tuple or empty array. \n\n20 bytes of data:\n```\nlength=0x3u64 2u32 1u32 3u32\n```\n8 bytes of data\n```\nlength=0xFFFFFFFu64\n```\n\nNow, this is not a problem if the individual elements take zero memory after parsing. Though, a common flaw is at least during serialization a large amount of memory will be required. If this case is not handled explicitly in the implementation then we are facing a DoS vector. For example, an implementation could decide to represent an array of ZST differently than a normal array and parse it in constant time, instead of looping and naively adding elements to an in-memory array.\n\nI mentioned that I believe this is a flaw in the specification. The reason for this is that the Ethereum ABI could have decided to disallow ZST completely. Actually, it turned out that in the latest versions of Solidity and Vyper it is not possible to define ZST like empty tuples or empty arrays. Even though the languages do not allow it, it is still allowed in the ABI specification.\n\n## POC\n\nWe define the data payload as `0x0000000000000000000000000000000000000000000000000000000000000020 00000000000000000000000000000000000000000000000000000000FFFFFFFF`. It consists of two 32-byte blocks, which describe a serialized array of ZST. The first block defines an offset to the array’s elements. The second block defines the length of the array. Independent of the programming language we will reference it always as payload.\n\nWe will try to decode this payload using the ABI schemata ()[] and uint32[0][]. The former represents a dynamic array of empty tuples and the latter a dynamic array of empty static arrays. The distinction between dynamic and static is important here, because an empty static array takes zero bytes, whereas a dynamic one takes a few bytes because it serializes the length of the array.\n\nThe following Python program uses the official eth_abi library and will hang and eventually cause an out-of-memory error.\n\n    from eth_abi import decode\n    data = bytearray.fromhex(payload)\n    decode(['()[]'], data)\n\n## SUGGESTED REMEDIATION\n\nWe suggest to disallow the parsing of ZST.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "eth-abi"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.2.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ethereum/eth-abi/security/advisories/GHSA-rqr8-pxh7-cq3g"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ethereum/eth-abi"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-11-24T16:54:11Z",
    "nvd_published_at" : null
  }
}