CVE-2026-30922: pyasn1 Vulnerable to Denial of Service via Unbounded Recursion

Published Mar 17, 2026
·
Updated

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 MAXASN1NESTING limit.

PoC import sys from pyasn1.codec.ber import decoder

sys.setrecursionlimit(100000)

print("[] Generating Recursion Bomb Payload...") depth = 50000 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.

Other sources

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.

This is a distinct vulnerability from CVE-2026-23490 (which addressed integer overflows in OID decoding). The fix for CVE-2026-23490 (MAXOIDARCCONTINUATIONOCTETS) does not mitigate this recursion issue.

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 MAXASN1NESTING limit.

PoC import sys from pyasn1.codec.ber import decoder

sys.setrecursionlimit(100000)

print("[] Generating Recursion Bomb Payload...") depth = 50000 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.

GitHub

pyasn1 is a generic ASN.1 library for Python. Prior to 0.6.3, 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 thousands of 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. This is a distinct vulnerability from CVE-2026-23490 (which addressed integer overflows in OID decoding). The fix for CVE-2026-23490 (MAXOIDARCCONTINUATIONOCTETS) does not mitigate this recursion issue. Version 0.6.3 fixes this specific issue.

NVD

pyasn1 Vulnerable to Denial of Service via Unbounded Recursion

Microsoft

Affected Software

6 affected componentsFixes available
pip/pyasn1<=0.6.2
0.6.3
Microsoft azl3 python-pyasn1 0.4.8-1
Microsoft cbl2 python-pyasn1 0.4.8-1
Microsoft azl3 python-pyasn1 0.4.8-2
pyasn1 Pyasn1 Python<0.6.3
IBM API Connect<=V10.0.8.0 - V10.0.8.9

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/pyasn1 to a version that resolves this vulnerability.

    Fixed in 0.6.3
  2. Upgrade

    Upgrade pyasn1 to a version that resolves this vulnerability.

    Fixed in 0.6.3
  3. Compensating control

    Set a strict Python recursion limit (e.g., avoid increasing it) on hosts running pyasn1 decoders processing untrusted ASN.1, to reduce the likelihood of uncontrolled recursion leading to RecursionError or OOM.

Event History

Mar 17, 2026
Advisory Published
via GitHub·04:17 PM
Data Sourced
via GitHub·04:17 PM
DescriptionSeverityWeaknessAffected Software
Mar 18, 2026
CVE Published
via MITRE·02:29 AM
Data Sourced
via MITRE·02:29 AM
DescriptionSeverityWeakness
Data Sourced
via Red Hat·04:04 AM
DescriptionSeverityAffected Software
Data Sourced
via NVD·04:17 AM
DescriptionSeverityWeakness
Data Sourced
via NVD·04:17 AM
RemedyAffected Software
Mar 21, 2026
Data Sourced
via Microsoft·08:02 AM
DescriptionSeverityWeaknessAffected Software
Updated
via Microsoft·08:02 AM
Affected Software
Updated
via Microsoft·08:02 AM
DescriptionSeverity
Jul 7, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-30922?

CVE-2026-30922 is classified as a Denial of Service (DoS) vulnerability.

2

How do I fix CVE-2026-30922?

To mitigate CVE-2026-30922, upgrade the pyasn1 library to version 0.6.3 or later.

3

What is the cause of CVE-2026-30922?

CVE-2026-30922 is caused by uncontrolled recursion when decoding ASN.1 data with deeply nested structures.

4

Which versions of pyasn1 are affected by CVE-2026-30922?

CVE-2026-30922 affects pyasn1 versions up to and including 0.6.2.

5

Can attackers exploit CVE-2026-30922?

Yes, attackers can exploit CVE-2026-30922 by supplying crafted payloads that induce excessive recursion.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203