CVE-2024-26134: Cbor2 Potential Buffer Overflow Vulnerability

HIGH
Advisory Identifier: GHSA-375g-39jq-vq7m
CVSS 7.5
CWE-120
Published
Advisory Summary

CVE-2024-26134 is a HIGH (CVSS 7.5) potential buffer overflow vulnerability (CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')) affecting Cbor2 libraries in the PyPI ecosystem. The issue involves potential buffer overflow in cbor2 decoder. Remediation is available by upgrading affected packages to version 5.6.2.

CVE-2024-26134 at a Glance

CVE Identifier CVE-2024-26134
GHSA Identifier GHSA-375g-39jq-vq7m
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')
Affected Product Cbor2
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-2024-26134

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

cbor2 fixed: 5.6.2
pip install cbor2>=5.6.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 cbor2

How to Check if You Are Affected

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

pip show cbor2

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow'), where the product copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer. In Cbor2, 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 Ever since https://github.com/agronholm/cbor2/pull/204 (or specifically https://github.com/agronholm/cbor2/commit/387755eacf0be35591a478d3c67fe10618a6d542) was merged, I can create a reproducible crash when running the snippet under PoC on a current Debian bullseye aarm64 on a Raspberry Pi 3 (I was **not** able to reproduce this on my x86_64 Laptop with Python 3.11; I suspect because there is enough memory to allocate still) ## Details ### PoC ```py import json import concurrent.futures import cbor2 def test(): obj = "x" * 131128 cbor_enc = cbor2.dumps(obj) return cbor2.loads(cbor_enc) with concurrent.futures.ProcessPoolExecutor() as executor: future = executor.submit(test) print(future.result()) ``` ``` malloc(): unsorted double linked list corrupted Traceback (most recent call last): File "test.py", line 14, in <module> print(future.result()) File "/usr/lib/python3.9/concurrent/futures/_base.py", line 440, in result return self.__get_result() File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result raise self._exception concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending. ``` If one calls it without the indirection via the pool executor, a SystemError is shown that hides the buffer overflow. ```py import json import cbor2 def test(): obj = "x" * 131128 cbor_enc = cbor2.dumps(obj) return cbor2.loads(cbor_enc) print(test()) ``` ``` Traceback (most recent call last): File "test.py", line 12, in <module> print(test()) File "test.py", line 9, in test return cbor2.loads(cbor_enc) SystemError: <built-in function loads> returned NULL without setting an error ``` ### Impact An attacker can crash a service using cbor2 to parse a CBOR binary by sending a long enough object.

CVE-2024-26134 Affected Cbor2 Versions

1 component(s)
Fixed Versions:
5.6.2
Product / Package Ecosystem Affected Versions Fixed Version
cbor2
PyPI
≥ 5.5.1
< 5.6.2
5.6.2

References

Frequently Asked Questions

What is CVE-2024-26134?
CVE-2024-26134 is a security vulnerability in Cbor2 involving Potential buffer overflow in CBOR2 decoder under CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow').
Which Cbor2 versions are affected?
Affected versions include releases prior to 5.6.2 across affected packages: cbor2.
What version fixes CVE-2024-26134?
Upgrading to 5.6.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cbor2 affected?
Yes, cbor2 is affected in releases prior to 5.6.2. Upgrade your dependency to 5.6.2 or later.
What is the CVSS score of CVE-2024-26134?
CVE-2024-26134 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-26134?
CVE-2024-26134 is classified under CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') (The product copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer.).
How can I check PyPI dependencies for CVE-2024-26134?
Run the dependency tree command: 'pip show cbor2'. 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-375g-39jq-vq7m",
  "modified" : "2025-01-14T15:59:39Z",
  "published" : "2024-02-21T00:09:03Z",
  "aliases" : [ "CVE-2024-26134" ],
  "summary" : "Potential buffer overflow in CBOR2 decoder",
  "details" : "### Summary\nEver since https://github.com/agronholm/cbor2/pull/204 (or specifically https://github.com/agronholm/cbor2/commit/387755eacf0be35591a478d3c67fe10618a6d542) was merged, I can create a reproducible crash when running the snippet under PoC on a current Debian bullseye aarm64 on a Raspberry Pi 3 (I was **not** able to reproduce this on my x86_64 Laptop with Python 3.11; I suspect because there is enough memory to allocate still)\n\n## Details\n\n\n### PoC\n```py\nimport json\nimport concurrent.futures\nimport cbor2\n\ndef test():\n    obj = \"x\" * 131128\n    cbor_enc = cbor2.dumps(obj)\n    return cbor2.loads(cbor_enc)\n\nwith concurrent.futures.ProcessPoolExecutor() as executor:\n    future = executor.submit(test)\n    print(future.result())\n```\n\n```\nmalloc(): unsorted double linked list corrupted\nTraceback (most recent call last):\n  File \"test.py\", line 14, in <module>\n    print(future.result())\n  File \"/usr/lib/python3.9/concurrent/futures/_base.py\", line 440, in result\n    return self.__get_result()\n  File \"/usr/lib/python3.9/concurrent/futures/_base.py\", line 389, in __get_result\n    raise self._exception\nconcurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.\n```\n\nIf one calls it without the indirection via the pool executor, a SystemError is shown that hides the buffer overflow.\n\n```py\nimport json\nimport cbor2\n\ndef test():\n    obj = \"x\" * 131128\n    cbor_enc = cbor2.dumps(obj)\n    return cbor2.loads(cbor_enc)\n\nprint(test())\n```\n\n```\nTraceback (most recent call last):\n  File \"test.py\", line 12, in <module>\n    print(test())\n  File \"test.py\", line 9, in test\n    return cbor2.loads(cbor_enc)\nSystemError: <built-in function loads> returned NULL without setting an error\n```\n\n### Impact\nAn attacker can crash a service using cbor2 to parse a CBOR binary by sending a long enough object.",
  "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" : "cbor2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.5.1"
      }, {
        "fixed" : "5.6.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/agronholm/cbor2/security/advisories/GHSA-375g-39jq-vq7m"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-26134"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/agronholm/cbor2/pull/204"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/agronholm/cbor2/commit/387755eacf0be35591a478d3c67fe10618a6d542"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/agronholm/cbor2/commit/4de6991ba29bf2290d7b9d83525eda7d021873df"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/agronholm/cbor2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/agronholm/cbor2/releases/tag/5.6.2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/cbor2/PYSEC-2024-155.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/BT42VXZMMMCSSHMA65KKPOZCXJEYHNR5"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/GX524ZG2XJWFV37UQKQ4LWIH4UICSGEQ"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PWC3VU6YV6EXKCSX5GTKWLBZIDIJNQJY"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-120" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-02-21T00:09:03Z",
    "nvd_published_at" : "2024-02-19T23:15:07Z"
  }
}