GHSA-jr27-m4p2-rc6r CVE-2026-30922 PYSEC-2026-2263
Denial of Service in pyasn1 via Unbounded Recursion
- Severity
- 7.5 / 10
- High · CVSS 3.0
- Exploit chance (EPSS)
- 0.82%
- Chance of exploitation in the next 30 days. Higher than 57.14% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-674 Uncontrolled Recursion
- CWE-835 Loop with Unreachable Exit Condition ('Infinite Loop')
- Fix
0.6.3- Upgrade pyasn1 to this version or later
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:
-
indefLenValueDecoder(Line 998):for component in decodeFun(substrate, asn1Spec, allowEoo=True, **options):This method handles indefinite-length constructed types. It sits inside awhile Trueloop and recursively calls the decoder for every nested tag. -
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 ofSEQUENCEorSETtypes. Line 907: Recursively decodes elements ofSEQUENCE OForSET OFtypes. -
_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
pyasn1to 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 versions
PyPI
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
pyasn1 PyPI → 0.6.3
- pip
pip install --upgrade "pyasn1>=0.6.3"- poetry
poetry add "pyasn1>=0.6.3"- uv
uv add "pyasn1>=0.6.3"
Severity breakdown
CVSS 3.0 7.5
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- High
Weakness
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 to prevent it
- Implementation: Ensure that an end condition will be reached under all logic conditions. The end condition may include checking against the depth of recursion and exiting with an error if the recursion goes too deep. The complexity of the end condition contributes to the effectiveness of this action.
- Implementation: Increase the stack size.
CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')
The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.
References
Advisories
Fixes and patches
Packages
Other links
- github.com/pyasn1/pyasn1/releases/tag/v0.6.3
- openwall.com/lists/oss-security/2026/03/20/4
- lists.debian.org/debian-lts-announce/2026/05/msg00001.html
- access.redhat.com/errata/RHSA-2026:22969
- access.redhat.com/errata/RHSA-2026:22970
- access.redhat.com/errata/RHSA-2026:22987
- access.redhat.com/errata/RHSA-2026:24761
- access.redhat.com/errata/RHSA-2026:24762
- access.redhat.com/errata/RHSA-2026:37275
- access.redhat.com/errata/RHSA-2026:41928
- access.redhat.com/errata/RHSA-2026:6309
- access.redhat.com/errata/RHSA-2026:6568
- access.redhat.com/errata/RHSA-2026:6720
- access.redhat.com/errata/RHSA-2026:6912
- access.redhat.com/errata/RHSA-2026:6926
- access.redhat.com/errata/RHSA-2026:8437
- access.redhat.com/security/cve/CVE-2026-30922
- bugzilla.redhat.com/show_bug.cgi
- github.com/pypa/advisory-database/tree/main/vulns/pyasn1/PYSEC-2026-2263.yaml
- security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-30922.json
- access.redhat.com/errata/RHSA-2026:10184
- access.redhat.com/errata/RHSA-2026:12176
- access.redhat.com/errata/RHSA-2026:13508
- access.redhat.com/errata/RHSA-2026:13512
- access.redhat.com/errata/RHSA-2026:13545
- access.redhat.com/errata/RHSA-2026:13553
- access.redhat.com/errata/RHSA-2026:13902
- access.redhat.com/errata/RHSA-2026:13916
- access.redhat.com/errata/RHSA-2026:13917
- access.redhat.com/errata/RHSA-2026:14020
- access.redhat.com/errata/RHSA-2026:16009
- access.redhat.com/errata/RHSA-2026:17083
- access.redhat.com/errata/RHSA-2026:17611
- access.redhat.com/errata/RHSA-2026:19138
- access.redhat.com/errata/RHSA-2026:19355
- access.redhat.com/errata/RHSA-2026:19375
- access.redhat.com/errata/RHSA-2026:19712
- access.redhat.com/errata/RHSA-2026:20588
- access.redhat.com/errata/RHSA-2026:22131
- access.redhat.com/errata/RHSA-2026:22132
- access.redhat.com/errata/RHSA-2026:22133
- access.redhat.com/errata/RHSA-2026:22134
- access.redhat.com/errata/RHSA-2026:22135
- access.redhat.com/errata/RHSA-2026:65126
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-2qm8-x737-gmw5 pyasn1 has quadratic CPU consumption in constructed BIT STRING decoding | High | Also affects pyasn1 |
| GHSA-mm57-4v3p-rchx pyasn1 has quadratic-complexity denial of service in binary REAL decoding | High | Also affects pyasn1 |
| GHSA-9m75-vc3g-4x39 pyasn1 has quadratic-time denial of service in constructed string and indefinite-length ANY decoding | High | Also affects pyasn1 |
| GHSA-fm9c-5rcf-2q5p pyasn1 has quadratic CPU use in schemaless BER/CER/DER container decoding | High | Also affects pyasn1 |
| GHSA-hm4w-wwcw-mr6r pyasn1: Uncontrolled resource consumption when converting decoded REAL values | High | Also affects pyasn1 |
| GHSA-8ppf-4f7h-5ppj pyasn1: Quadratic complexity in OBJECT IDENTIFIER and RELATIVE-OID processing allows denial of service | High | Also affects pyasn1 |
| GHSA-m4p7-r5rc-7g4j pyasn1 BER/CER/DER decoder denial of service via unbounded long-form tag IDs | High | Also affects pyasn1 |
| GHSA-63vm-454h-vhhq pyasn1 has a DoS vulnerability in decoder | High | Also affects pyasn1 |
Credits: romanticpragmatism
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor