cbor2
Affected
- introduced
0, fixed5.9.0(ecosystem)
Fixed versions
5.9.0
Fix
- Fixed version
5.9.0pip install --upgrade cbor2==5.9.0
Advisory
Also known as: CVE-2026-26209, PYSEC-2026-2123
cbor2 has a Denial of Service via Uncontrolled Recursion in cbor2.loads
Summary
cbor2 library is vulnerable to a Denial of Service (DoS) attack caused by uncontrolled recursion when decoding deeply nested CBOR structures._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.0x81). When cbor2.loads() attempts to parse this, it hits the interpreter's recursion limit, causing the call to raise a RecursionError.Details
CBORDecoder class, specifically how it decodes nested container types like Arrays and Maps.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.cbor2/decoder.py (Pure Python implementation)source/decoder.c (C extension implementation)cbor2.loads() function initializes a CBORDecoder and calls its decode() method.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.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
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).Credit
This issue was discovered by Kevin Tu of TMIR at ByteDance. The patch was developed by @agronholm.
High Basis: The source's own band: HIGH
0, fixed 5.9.0 (ecosystem)5.9.0
5.9.0pip install --upgrade cbor2==5.9.0Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0