GHSA-jr27-m4p2-rc6r
Denial of Service in pyasn1 via Unbounded Recursion
At a glance
- Published
- Updated
- CVE
- CVE-2026-30922
- Aliases
- PYSEC-2026-2263
- CVSS_V3
- CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Description
### Summary The `pyasn1` library is vulnerable to a Denial of Service (DoS) attack caused by uncontrolled recursion when decoding ASN.1 data with deeply nested structures. An attacker can supply a crafted payload containing nested `SEQUENCE` (`0x30`) or `SET` (`0x31`) tags with Indefinite Length (`0x80`) markers. This forces the decoder to recursively call itself until the Python interpreter crashes with a `RecursionError` or consumes all available memory (OOM), crashing the host application. ### Details The vulnerability exists because the decoder iterates through the input stream and recursively calls `decodeFun` (the decoding callback) for every nested component found, without tracking or limiting the recursion depth. Vulnerable Code Locations: 1. `indefLenValueDecoder` (Line 998): ```for component in decodeFun(substrate, asn1Spec, allowEoo=True, **options):``` This method handles indefinite-length constructed types. It sits inside a `while True` loop and recursively calls the decoder for every nested tag. 2. `valueDecoder` (Lines 786 and 907): ```for component in decodeFun(substrate, componentType, **options):``` This method handles standard decoding when a schema is present. It contains two distinct recursive calls that lack depth checks: Line 786: Recursively decodes components of `SEQUENCE` or `SET` types. Line 907: Recursively decodes elements of `SEQUENCE OF` or `SET OF` types. 4. `_decodeComponentsSchemaless` (Line 661): ```for component in decodeFun(substrate, **options):``` This method handles decoding when no schema is provided. In all three cases, `decodeFun` is invoked without passing a `depth` parameter or checking against a global `MAX_ASN1_NESTING` limit. ### PoC ``` import sys from pyasn1.codec.ber import decoder sys.setrecursionlimit(100000) print("[*] Generating Recursion Bomb Payload...") depth = 50_000 chunk = b'\x30\x80' payload = chunk * depth print(f"[*] Payload size: {len(payload) / 1024:.2f} KB") print("[*] Triggering Decoder...") try: decoder.decode(payload) except RecursionError: print("[!] Crashed: Recursion Limit Hit") except MemoryError: print("[!] Crashed: Out of Memory") except Exception as e: print(f"[!] Crashed: {e}") ``` ``` [*] Payload size: 9.77 KB [*] Triggering Decoder... [!] Crashed: Recursion Limit Hit ``` ### Impact - This is an unhandled runtime exception that typically terminates the worker process or thread handling the request. This allows a remote attacker to trivially kill service workers with a small payload (<100KB), resulting in a Denial of Service. Furthermore, in environments where recursion limits are increased, this leads to server-wide memory exhaustion. - Service Crash: Any service using `pyasn1` to parse untrusted ASN.1 data (e.g., LDAP, SNMP, Kerberos, X.509 parsers) can be crashed remotely. - Resource Exhaustion: The attack consumes RAM linearly with the nesting depth. A small payload (<200KB) can consume hundreds of megabytes of RAM or exhaust the stack. ### Credits Vulnerability discovered by Kevin Tu of TMIR at ByteDance.
Affected packages
| Package | Versions |
|---|---|
| PyPI · pyasn1 | introduced 0, fixed 0.6.3 |
References
- https://github.com/pyasn1/pyasn1/security/advisories/GHSA-jr27-m4p2-rc6r WEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-30922 ADVISORY
- https://github.com/pyasn1/pyasn1/commit/5a49bd1fe93b5b866a1210f6bf0a3924f21572c8 WEB
- https://github.com/pyasn1/pyasn1/commit/25ad481c19fdb006e20485ef3fc2e5b3eff30ef0 WEB
- https://access.redhat.com/errata/RHSA-2026:22970 WEB
- https://access.redhat.com/errata/RHSA-2026:22987 WEB
- https://access.redhat.com/errata/RHSA-2026:24761 WEB
- https://access.redhat.com/errata/RHSA-2026:24762 WEB
- https://access.redhat.com/errata/RHSA-2026:37275 WEB
- https://access.redhat.com/errata/RHSA-2026:41928 WEB
- https://access.redhat.com/errata/RHSA-2026:6309 WEB
- https://access.redhat.com/errata/RHSA-2026:65126 WEB
- https://access.redhat.com/errata/RHSA-2026:6568 WEB
- https://access.redhat.com/errata/RHSA-2026:6720 WEB
- https://access.redhat.com/errata/RHSA-2026:6912 WEB
- https://access.redhat.com/errata/RHSA-2026:6926 WEB
- https://access.redhat.com/errata/RHSA-2026:8437 WEB
- https://access.redhat.com/security/cve/CVE-2026-30922 WEB
- https://bugzilla.redhat.com/show_bug.cgi?id=2448553 WEB
- https://github.com/pyasn1/pyasn1 PACKAGE
- https://github.com/pyasn1/pyasn1/releases/tag/v0.6.3 WEB
- https://github.com/pypa/advisory-database/tree/main/vulns/pyasn1/PYSEC-2026-2263.yaml WEB
- https://lists.debian.org/debian-lts-announce/2026/05/msg00001.html WEB
- https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-30922.json WEB
- https://access.redhat.com/errata/RHSA-2026:10184 WEB
- https://access.redhat.com/errata/RHSA-2026:12176 WEB
- https://access.redhat.com/errata/RHSA-2026:13508 WEB
- https://access.redhat.com/errata/RHSA-2026:13512 WEB
- https://access.redhat.com/errata/RHSA-2026:13545 WEB
- https://access.redhat.com/errata/RHSA-2026:13553 WEB
- https://access.redhat.com/errata/RHSA-2026:13902 WEB
- https://access.redhat.com/errata/RHSA-2026:13916 WEB
- https://access.redhat.com/errata/RHSA-2026:13917 WEB
- https://access.redhat.com/errata/RHSA-2026:14020 WEB
- https://access.redhat.com/errata/RHSA-2026:16009 WEB
- https://access.redhat.com/errata/RHSA-2026:17083 WEB
- https://access.redhat.com/errata/RHSA-2026:17611 WEB
- https://access.redhat.com/errata/RHSA-2026:19138 WEB
- https://access.redhat.com/errata/RHSA-2026:19355 WEB
- https://access.redhat.com/errata/RHSA-2026:19375 WEB
- https://access.redhat.com/errata/RHSA-2026:19712 WEB
- https://access.redhat.com/errata/RHSA-2026:20588 WEB
- https://access.redhat.com/errata/RHSA-2026:22131 WEB
- https://access.redhat.com/errata/RHSA-2026:22132 WEB
- https://access.redhat.com/errata/RHSA-2026:22133 WEB
- https://access.redhat.com/errata/RHSA-2026:22134 WEB
- https://access.redhat.com/errata/RHSA-2026:22135 WEB
- https://access.redhat.com/errata/RHSA-2026:22969 WEB
- http://www.openwall.com/lists/oss-security/2026/03/20/4 WEB
Sources
| Source | Licence |
|---|---|
| OSV.dev | CC-BY 4.0 — GitHub Advisory Database |