{"id":"CVE-2026-26209","aliases":["CVE-2026-26209","GHSA-3c37-wwvx-h642","PYSEC-2026-2123"],"related":[],"kind":"vulnerability","state":"published","title":"cbor2 has a Denial of Service via Uncontrolled Recursion in cbor2.loads","summary":"cbor2 provides encoding and decoding for the Concise Binary Object Representation (CBOR) serialization format. Versions prior to 5.9.0 are 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 relies on Python's internal recursion limits `Py_EnterRecursiveCall` rather than a data-driven depth limit, meaning it still raises `RecursionError` and crashes the worker process when the limit is hit. While the library handles moderate nesting levels, it lacks a hard depth limit. An attacker can supply a crafted CBOR payload containing approximately 100,000 nested arrays `0x81`. When `cbor2.loads()` attempts to parse this, it hits the Python interpreter's maximum recursion depth or exhausts the stack, causing the process to crash with a `RecursionError`. Because the library does not enforce its own limits, it allows an external attacker to exhaust the host application's stack resource. In many web application servers (e.g., Gunicorn, Uvicorn) or task queues (Celery), an unhandled `RecursionError` terminates the worker process immediately. By sending a stream of these small (<100KB) malicious packets, an attacker can repeatedly crash worker processes, resulting in a complete Denial of Service for the application. Version 5.9.0 patches the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"cbor2 provides encoding and decoding for the Concise Binary Object Representation (CBOR) serialization format. Versions prior to 5.9.0 are 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 relies on Python's internal recursion limits `Py_EnterRecursiveCall` rather than a data-driven depth limit, meaning it still raises `RecursionError` and crashes the worker process when the limit is hit. While the library handles moderate nesting levels, it lacks a hard depth limit. An attacker can supply a crafted CBOR payload containing approximately 100,000 nested arrays `0x81`. When `cbor2.loads()` attempts to parse this, it hits the Python interpreter's maximum recursion depth or exhausts the stack, causing the process to crash with a `RecursionError`. Because the library does not enforce its own limits, it allows an external attacker to exhaust the host application's stack resource. In many web application servers (e.g., Gunicorn, Uvicorn) or task queues (Celery), an unhandled `RecursionError` terminates the worker process immediately. By sending a stream of these small (<100KB) malicious packets, an attacker can repeatedly crash worker processes, resulting in a complete Denial of Service for the application. Version 5.9.0 patches the issue.","source":"cvelist"},{"lang":"en","text":"### 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.","format":"markdown","source":"ghsa"},{"lang":"es","text":"cbor2 proporciona codificación y decodificación para el formato de serialización Concise Binary Object Representation (CBOR). Las versiones anteriores a la 5.9.0 son vulnerables a un ataque de denegación de servicio (DoS) causado por recursión incontrolada al decodificar estructuras CBOR profundamente anidadas. Esta vulnerabilidad afecta tanto a la implementación pura de Python como a la extensión C '_cbor2'. La extensión C se basa en los límites de recursión internos de Python 'Py_EnterRecursiveCall' en lugar de un límite de profundidad basado en datos, lo que significa que aún genera 'RecursionError' y bloquea el proceso de trabajo cuando se alcanza el límite. Aunque la biblioteca maneja niveles de anidamiento moderados, carece de un límite de profundidad estricto. Un atacante puede proporcionar una carga útil CBOR manipulada que contenga aproximadamente 100.000 arrays anidados '0x81'. Cuando 'cbor2.loads()' intenta analizar esto, alcanza la profundidad máxima de recursión del intérprete de Python o agota la pila, lo que provoca que el proceso falle con un 'RecursionError'. Debido a que la biblioteca no impone sus propios límites, permite que un atacante externo agote el recurso de pila de la aplicación anfitriona. En muchos servidores de aplicaciones web (p. ej., Gunicorn, Uvicorn) o colas de tareas (Celery), un 'RecursionError' no manejado termina el proceso de trabajo inmediatamente. Al enviar un flujo de estos pequeños paquetes maliciosos (&lt;100KB), un atacante puede bloquear repetidamente los procesos de trabajo, lo que resulta en una denegación de servicio completa para la aplicación. La versión 5.9.0 corrige el problema.","source":"nvd"}],"published":"2026-03-23T18:53:10.268Z","modified":"2026-09-10T03:50:36.691Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.0","vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.0","vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.0","vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.0","vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-674"],"affected":[{"ranges":[{"version":"< 5.9.0","status":"affected"}],"vendor":"agronholm","product":"cbor2","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"5.9.0"}],"ecosystem":"PyPI","package":"cbor2","purl":"pkg:pypi/cbor2","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"5.9.0"}],"vendor":"agronholm","product":"cbor2","cpe":"cpe:2.3:a:agronholm:cbor2:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"5.9.0"}],"ecosystem":"PyPI","package":"cbor2","purl":"pkg:pypi/cbor2","source":"pysec"}],"references":[{"url":"https://github.com/agronholm/cbor2/security/advisories/GHSA-3c37-wwvx-h642","tags":["evidence","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/agronholm/cbor2/pull/275","tags":["fix","issue-tracking","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/agronholm/cbor2/commit/e61a5f365ba610d5907a0ae1bc72769bba34294b","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/agronholm/cbor2/releases/tag/5.9.0","tags":["advisory","product","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-26209","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/agronholm/cbor2","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-03-24T18:35:22.617Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-26209","url":"https://www.cve.org/CVERecord?id=CVE-2026-26209","licence":"CVE Terms of Use","modified":"2026-03-24T18:35:35.486Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3c37-wwvx-h642","url":"https://github.com/advisories/GHSA-3c37-wwvx-h642","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:36.691Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-26209","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-26209","licence":"Public domain","modified":"2026-06-17T10:25:56.800Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2123","url":"https://osv.dev/vulnerability/PYSEC-2026-2123","licence":"CC-BY-4.0","modified":"2026-07-13T07:15:16.978Z"}],"updatedAt":"2026-11-25T22:59:16.475Z","epss":{"score":0.00533,"percentile":0.46454,"date":"2026-12-01T12:00:22.000Z"}}