CVE-2026-26209: Cbor2 Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-3c37-wwvx-h642
CVSS 7.5
CWE-674
Published
Advisory Summary

CVE-2026-26209 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-674: Uncontrolled Recursion) affecting Cbor2 libraries in the PyPI ecosystem. The issue involves cbor2 has a denial of service via uncontrolled recursion in cbor2.loads. Remediation is available by upgrading affected packages to version 5.9.0.

CVE-2026-26209 at a Glance

CVE Identifier CVE-2026-26209
GHSA Identifier GHSA-3c37-wwvx-h642
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-674: Uncontrolled Recursion
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.0/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-2026-26209

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.9.0
pip install cbor2>=5.9.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 cbor2

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-26209, 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.9.0), 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-674: Uncontrolled Recursion, where the product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. 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 - The `cbor2` library is vulnerable to a Denial of Service (DoS) attack caused by uncontrolled recursion when decoding deeply nested CBOR structures. - This vulnerability affects both the pure Python implementation and the C extension (`_cbor2`). The C extension correctly uses Python's C-API for recursion protection (`Py_EnterRecursiveCall`), but this mechanism is designed to prevent a stack overflow by raising a `RecursionError`. In some environments, this exception is not caught, thus causing the service process to terminate. - While the library handles moderate nesting, it lacks a configurable, data-driven depth limit independent of Python's global recursion setting. An attacker can supply a crafted CBOR payload containing thousands of nested arrays (e.g., `0x81`). When `cbor2.loads()` attempts to parse this, it hits the interpreter's recursion limit, causing the call to raise a `RecursionError`. - By sending a stream of small (<100KB) malicious packets, an attacker can repeatedly crash worker processes faster than they can be restarted, resulting in a complete and sustained Denial of Service. ### Details - The vulnerability stems from the recursive design of the `CBORDecoder` class, specifically how it decodes nested container types like Arrays and Maps. - Inside `decode_array` (and similarly `decode_map`), the decoder iterates through the number of elements specified in the CBOR header. For each element, it calls `self.decode()` again to parse the nested item. This recursive call lacks a depth-tracking mechanism. - Vulnerable Code Locations: - `cbor2/decoder.py` (Pure Python implementation) - `source/decoder.c` (C extension implementation) - Execution Flow: 1. The `cbor2.loads()` function initializes a `CBORDecoder` and calls its `decode()` method. 2. The `decode()` method reads the initial byte and dispatches control to a specific handler based on the major type. For an Array (Major Type 4), it calls `decode_array`. 3. `decode_array` loops and calls `self.decode()` for each item, leading to deep recursion when parsing a payload like `[...[...[1]...]...]`. ### PoC ``` import cbor2 DEPTH = 1000 payload = b'\x81' * DEPTH + b'\x01' print(f"[*] Payload size: {len(payload) / 1024:.2f} KB") print("[*] Triggering decoder...") try: cbor2.loads(payload) print("[+] Parsed successfully (Not Vulnerable)") except RecursionError: print("\n[!] VULNERABLE: RecursionError triggered!") except Exception as e: print(f"\n[-] Unexpected Error: {type(e).__name__}: {e}") ``` ### Impact - Scope: This vulnerability affects any application using `cbor2` to parse untrusted data. Common use cases include IoT data processing, WebAuthn (FIDO2) authentication flows, and inter-service communication over COSE (CBOR Object Signing and Encryption). - Attack Vector: A remote, unauthenticated attacker can achieve a full Denial of Service with a highly efficient, low-bandwidth attack. A payload under 100KB is sufficient to reliably terminate a Python worker process. ### Credit This issue was discovered by Kevin Tu of TMIR at ByteDance. The patch was developed by @agronholm.

CVE-2026-26209 Affected Cbor2 Versions

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

References

Frequently Asked Questions

What is CVE-2026-26209?
CVE-2026-26209 is a security vulnerability in Cbor2 involving cbor2 has a Denial of Service via Uncontrolled Recursion in cbor2.loads under CWE-674: Uncontrolled Recursion.
Which Cbor2 versions are affected?
Affected versions include releases prior to 5.9.0 across affected packages: cbor2.
What version fixes CVE-2026-26209?
Upgrading to 5.9.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cbor2 affected?
Yes, cbor2 is affected in releases prior to 5.9.0. Upgrade your dependency to 5.9.0 or later.
What is the CVSS score of CVE-2026-26209?
CVE-2026-26209 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-26209?
CVE-2026-26209 is classified under CWE-674: Uncontrolled Recursion (The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.).
How can I check PyPI dependencies for CVE-2026-26209?
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-3c37-wwvx-h642",
  "modified" : "2026-03-25T20:38:41Z",
  "published" : "2026-03-23T20:23:57Z",
  "aliases" : [ "CVE-2026-26209" ],
  "summary" : "cbor2 has a Denial of Service via Uncontrolled Recursion in cbor2.loads",
  "details" : "### Summary\n\n- The `cbor2` library is vulnerable to a Denial of Service (DoS) attack caused by uncontrolled recursion when decoding deeply nested CBOR structures.\n- This vulnerability affects both the pure Python implementation and the C extension (`_cbor2`). The C extension correctly uses Python's C-API for recursion protection (`Py_EnterRecursiveCall`), but this mechanism is designed to prevent a stack overflow by raising a `RecursionError`. In some environments, this exception is not caught, thus causing the service process to terminate.\n- While the library handles moderate nesting, it lacks a configurable, data-driven depth limit independent of Python's global recursion setting. An attacker can supply a crafted CBOR payload containing thousands of nested arrays (e.g., `0x81`). When `cbor2.loads()` attempts to parse this, it hits the interpreter's recursion limit, causing the call to raise a `RecursionError`.\n- By sending a stream of small (<100KB) malicious packets, an attacker can repeatedly crash worker processes faster than they can be restarted, resulting in a complete and sustained Denial of Service.\n\n### Details\n\n- The vulnerability stems from the recursive design of the `CBORDecoder` class, specifically how it decodes nested container types like Arrays and Maps.\n- Inside `decode_array` (and similarly `decode_map`), the decoder iterates through the number of elements specified in the CBOR header. For each element, it calls `self.decode()` again to parse the nested item. This recursive call lacks a depth-tracking mechanism.\n- Vulnerable Code Locations:\n  - `cbor2/decoder.py` (Pure Python implementation)\n  - `source/decoder.c` (C extension implementation)\n- Execution Flow:\n  1. The `cbor2.loads()` function initializes a `CBORDecoder` and calls its `decode()` method.\n  2. The `decode()` method reads the initial byte and dispatches control to a specific handler based on the major type. For an Array (Major Type 4), it calls `decode_array`.\n  3. `decode_array` loops and calls `self.decode()` for each item, leading to deep recursion when parsing a payload like `[...[...[1]...]...]`.\n\n### PoC\n\n```\nimport cbor2\n\nDEPTH = 1000\n\npayload = b'\\x81' * DEPTH + b'\\x01'\nprint(f\"[*] Payload size: {len(payload) / 1024:.2f} KB\")\nprint(\"[*] Triggering decoder...\")\n\ntry:\n    cbor2.loads(payload)\n    print(\"[+] Parsed successfully (Not Vulnerable)\")\nexcept RecursionError:\n    print(\"\\n[!] VULNERABLE: RecursionError triggered!\")\nexcept Exception as e:\n    print(f\"\\n[-] Unexpected Error: {type(e).__name__}: {e}\")\n```\n\n### Impact\n\n- Scope: This vulnerability affects any application using `cbor2` to parse untrusted data. Common use cases include IoT data processing, WebAuthn (FIDO2) authentication flows, and inter-service communication over COSE (CBOR Object Signing and Encryption).\n- Attack Vector: A remote, unauthenticated attacker can achieve a full Denial of Service with a highly efficient, low-bandwidth attack. A payload under 100KB is sufficient to reliably terminate a Python worker process.\n\n### Credit\n\nThis issue was discovered by Kevin Tu of TMIR at ByteDance. The patch was developed by @agronholm.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/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" : "0"
      }, {
        "fixed" : "5.9.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.8.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/agronholm/cbor2/security/advisories/GHSA-3c37-wwvx-h642"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-26209"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/agronholm/cbor2/pull/275"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/agronholm/cbor2/commit/e61a5f365ba610d5907a0ae1bc72769bba34294b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/agronholm/cbor2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/agronholm/cbor2/releases/tag/5.9.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-674" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-23T20:23:57Z",
    "nvd_published_at" : "2026-03-23T19:16:39Z"
  }
}