CVE-2026-119195: pyasn1 has quadratic-time denial of service in constructed string and indefinite-length ANY decoding
pyasn1 0.6.4 and earlier decode constructed OCTET STRINGs, character strings and indefinite-length ANY values in quadratic time. A megabyte-scale input made of many tiny fragments can hold a decoder worker for seconds. Applications that decode untrusted ASN.1 are exposed to CPU exhaustion. Fixed in pyasn1 0.6.5.
Published Oct 30, 2026 · Analysis Oct 31, 2026
What an attacker can do
The decoder appends each fragment to a growing bytes value with header += component (OctetStringPayloadDecoder, definite and indefinite forms) and chunk += component (AnyPayloadDecoder.indefLenValueDecoder). Each concatenation copies the whole prefix, so N fragments cost about N squared in copying while the input grows linearly. The OCTET STRING decoder is the base class for UTF8String, PrintableString, IA5String, BMPString, GeneralizedTime, UTCTime and other string types, so they inherit the flaw.
BER and CER are affected. DER normally rejects constructed strings, but with asn1Spec=univ.OctetString() it accepts the definite-length form, and it accepts a constructed UTF8String without any schema. Indefinite-length ANY needs an asn1Spec of univ.Any in BER or CER.
Reporter measurements on v0.6.4: a 1.60 MB BER constructed OCTET STRING of 400,000 two-byte fragments took 2.738 s, against 0.623 s fixed. A 1.20 MB indefinite ANY took 3.980 s. The original report saw 16.05 s for a 3.2 MB input. Nothing in v0.6.4 caps the number of sibling fragments. Impact is availability only. Whether it is reachable before login depends on your application.
Who is affected
The pip package pyasn1, all versions <= 0.6.4. Your code is exposed if it passes untrusted bytes to ber, cer or der decode() or to StreamingDecoder without a size limit. Check the version:
pip show pyasn1This is a separate bug from the OBJECT IDENTIFIER accumulation issue fixed in 0.6.4, so a copy already on 0.6.4 is still vulnerable.
pyasn1
- Ecosystem
- PyPI
- Affected
- <= 0.6.4
- Fixed in
- 0.6.5
- Check
pip show pyasn1
How to fix it
Upgrade to pyasn1 0.6.5.
pip install --upgrade "pyasn1>=0.6.5"The release replaces the growing bytes accumulator with a list of fragments joined once at the end, in all three affected loops. The advisory gives these workarounds until you upgrade: enforce a size limit on untrusted ASN.1 before it reaches pyasn1, limit the CPU available to decoding workers, and, for DER-only protocols, reject constructed string encodings before calling the decoder.
How to tell if you were hit
Watch for decoder workers stuck at full CPU on inputs of a megabyte or more, and for slow requests whose payload is a constructed string (tag 0x24, or 0x2c for UTF8String) or an indefinite-length SEQUENCE (0x30 0x80) holding very many tiny elements. Repeated large ASN.1 uploads from a single client are the pattern to look for. Profiles should show time in the BER decoder's string and ANY payload decoders. Run pip show pyasn1 across images to list versions at or below 0.6.4.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Summary
In pyasn1 0.6.4 and earlier, decoding a constructed OCTET STRING or character string made of many fragments can spend disproportionate CPU time repeatedly copying the accumulated value. A separate indefinite-length ANY path has the same problem while collecting the encoded components. The work grows roughly quadratically with the number of fixed-size fragments, although the input and decoded value grow linearly. An application that lets an attacker supply such ASN.1 input to an affected decoder can suffer CPU exhaustion.
The affected string paths are available in BER and CER. The DER decoder also accepts certain *non-DER* constructed strings: a definite-length constructed OCTET STRING when an asn1Spec selects univ.OctetString, and constructed character strings such as UTF8String even without a schema. Indefinite-length ANY is affected in BER and CER when an asn1Spec selects univ.Any; DER rejects indefinite lengths.
This is a distinct decoder path from the OBJECT IDENTIFIER/RELATIVE-OID accumulation addressed by CVE-2026-59885. It has the same complexity class, but the OID fix in 0.6.4 did not change these string or ANY loops.
Technical details
In the v0.6.4 BER decoder, OctetStringPayloadDecoder appends each decoded fragment to a growing bytes value with header += component in both its definite-length and indefinite-length constructed forms. `AnyPayloadDecoder.indefLenValueDecoder` similarly uses chunk += component. In the exercised paths, each concatenation copies an increasingly large prefix. For N fixed-size fragments, the total copied data grows with 1 + 2 + ... + N, or O(N²).
The OCTET STRING decoder is also the base class of the decoders for UTF8String, NumericString, PrintableString, TeletexString, VideotexString, IA5String, GraphicString, VisibleString, GeneralString, UniversalString, BMPString, ObjectDescriptor, GeneralizedTime, and UTCTime. These types inherit the same constructed-string reassembly path.
The DER decoder's OCTET STRING restriction replaces the tag-driven decoder, but its schema-driven TYPE_MAP retains the BER-derived decoder. Thus der.decode(data) rejects a constructed OCTET STRING, while der.decode(data, asn1Spec=univ.OctetString()) accepts its definite-length form and reaches the accumulation loop. DER does not replace the inherited character-string decoders, so a constructed UTF8String is also accepted without asn1Spec. These inputs violate X.690's DER string-encoding rule and should not be described as valid DER encodings.
The original short-fragment, definite-length OCTET STRING reproducer is valid BER. The CER decoder accepts it, but it is not a conforming CER string encoding: X.690 requires an indefinite-length outer constructed string and 1,000 contents octets per fragment except possibly the last. A conforming CER-shaped constructed OCTET STRING with those fragment sizes also reaches the loop and shows quadratic growth. The indefinite-length ANY reproducer below can represent a CER SEQUENCE OF OCTET STRING and reaches the separate ANY loop when decoded with an ANY schema.
The decoder's eight-octet length-field limit and nesting-depth limit do not bound the number of sibling fragments in these examples. The BER reproducer below uses only a three-octet outer length field; all fragments have shallow nesting. There is no per-message fragment-count cap in v0.6.4.
Impact
If an application passes attacker-controlled ASN.1 to the affected decode() or StreamingDecoder path without an adequate input or resource limit, a megabyte-scale value can occupy a decoding worker for seconds. Repeated inputs can exhaust available CPU. Whether this is reachable before authentication, or through a particular protocol, depends on the application; the library finding alone does not establish those conditions. No confidentiality or integrity impact is claimed.
Severity assessment (CVSS v3.1)
The 7.5 Base score assumes a reasonable application that automatically decodes attacker-supplied ASN.1 from unauthenticated network input. Valid BER and conforming CER inputs trigger the string-reassembly issue without special conditions, privileges, or user interaction. Repeated crafted inputs could occupy all available decoder workers and deny service while the attack continues. No confidentiality or integrity impact is demonstrated. This library-level score does not assert that every adopter has such an endpoint or loses all service; deployment-specific input limits and architecture may change the score. See FIRST's library-scoring guidance.
On the official v0.6.4 tag, local CPU-time measurements with CPython 3.14.8 on macOS arm64 gave the following results. Times vary by machine and Python runtime; the input-size scaling is the relevant observation. “Fixed” means the local 0.6.5 decoder fix applied to the same inputs.
| Decoder path and input | Fragments | v0.6.4 CPU | Fixed CPU | | BER constructed OCTET STRING, 0.40 MB | 100,000 × 2 payload bytes | 0.340 s | 0.160 s | | BER constructed OCTET STRING, 0.80 MB | 200,000 × 2 payload bytes | 0.886 s | 0.312 s | | BER constructed OCTET STRING, 1.60 MB | 400,000 × 2 payload bytes | 2.738 s | 0.623 s | | BER indefinite `ANY`, 0.30 MB | 100,000 × 1 payload byte | 0.459 s | 0.206 s | | BER indefinite `ANY`, 0.60 MB | 200,000 × 1 payload byte | 1.245 s | 0.412 s | | BER indefinite `ANY`, 1.20 MB | 400,000 × 1 payload byte | 3.980 s | 0.826 s | | CER constructed OCTET STRING, 1.00 MB, conforming fragment layout | 1,000 × 1,000 payload bytes | 0.0089 s | 0.0022 s | | CER constructed OCTET STRING, 2.01 MB, conforming fragment layout | 2,000 × 1,000 payload bytes | 0.0311 s | 0.0044 s | | CER constructed OCTET STRING, 4.02 MB, conforming fragment layout | 4,000 × 1,000 payload bytes | 0.1379 s | 0.0090 s |
For the same short-fragment layout, the original report measured up to 16.05 seconds for a 3.2 MB BER constructed OCTET STRING. An independent report on CPython 3.11.16/Linux measured 5.76 seconds for a 2.4 MB constructed OCTET STRING, versus about 0.005 seconds for a primitive OCTET STRING of comparable size. These are reporter measurements on different systems, not fixed performance guarantees.
Reproduction
This example uses public decoder APIs. Run it with pyasn1 0.6.4 and increase n to observe the scaling. The final two calls show the DER paths accepted by v0.6.4; their constructed encodings are not valid DER.
import time
from pyasn1.codec.ber import decoder as ber
from pyasn1.codec.cer import decoder as cer
from pyasn1.codec.der import decoder as der
from pyasn1.type import univ
def tlv(identifier, contents):
length = len(contents)
if length < 128:
return bytes((identifier, length)) + contents
encoded = length.to_bytes((length.bit_length() + 7) // 8, "big")
return bytes((identifier, 0x80 | len(encoded))) + encoded + contents
def measure(label, decode, substrate, asn1Spec=None):
start = time.process_time()
_, rest = decode(substrate, asn1Spec=asn1Spec)
assert not rest
print(f"{label}: {len(substrate)} input bytes, "
f"{time.process_time() - start:.3f} CPU seconds")
n = 100_000
octet_fragments = b"\x04\x02AA" * n
utf8_fragments = b"\x0c\x02AA" * n
measure("BER constructed OCTET STRING", ber.decode,
tlv(0x24, octet_fragments))
measure("BER indefinite ANY", ber.decode,
b"\x30\x80" + b"\x04\x01A" * n + b"\x00\x00",
univ.Any())
# CER uses indefinite length and 1,000-content-octet primitive fragments.
cer_fragment = tlv(0x04, b"A" * 1000)
measure("CER constructed OCTET STRING", cer.decode,
b"\x24\x80" + cer_fragment * 1000 + b"\x00\x00")
# These constructed encodings are accepted by pyasn1 but are invalid DER.
measure("DER OCTET STRING with schema", der.decode,
tlv(0x24, octet_fragments), univ.OctetString())
measure("DER UTF8String without schema", der.decode,
tlv(0x2c, utf8_fragments))Patch
pyasn1 0.6.5 replaces the growing bytes accumulator with a list of fragments and joins them once after decoding in all three affected loops. The OCTET STRING base-class change also covers the inheriting character-string decoders. This removes the repeated copying while preserving the assembled decoded value.
Workaround
Until upgrading, enforce application-appropriate limits on the size of untrusted ASN.1 input *before* passing it to pyasn1, and limit the CPU resources available to decoding workers. Applications that require DER can also reject constructed string encodings before invoking the decoder. The appropriate byte limit depends on the protocol and expected valid values.
Credits and references
Reported by alimony. Independently reported by manus-pi, whose report identified the schema-driven DER route, inherited character-string decoders, and additional performance evidence.
Credited to alimony, manus-pi, adriank31.
Questions
- I already upgraded to pyasn1 0.6.4 for the OID issue. Am I safe?
No. This is a different decoder path. The OID fix in 0.6.4 did not change the string or ANY loops. You need 0.6.5.
- Does DER decoding protect me?
Not fully. v0.6.4 DER accepts a constructed OCTET STRING when an asn1Spec selects univ.OctetString, and a constructed UTF8String without a schema. Those inputs reach the slow loop.
- Can it be exploited before authentication?
The advisory says that depends on your application. The 7.5 score assumes unauthenticated network input that is decoded automatically. The library alone does not establish that.
- Does it allow code execution or data exposure?
No. The advisory claims no confidentiality or integrity impact. The harm is CPU exhaustion and reduced availability.
References
Read for this analysis:
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More PyPI vulnerabilities
All PyPI entriesCVE-2026-119194
pyasn1 has quadratic CPU use in schemaless BER/CER/DER container decoding
high7.5Oct 30, 2026CVE-2026-119196
pyasn1 has quadratic CPU consumption in constructed BIT STRING decoding
high7.5Oct 30, 2026CVE-2026-119197
pyasn1 has quadratic-complexity denial of service in binary REAL decoding
high7.5Oct 30, 2026CVE-2026-59884
pyasn1 BER/CER/DER decoder denial of service via unbounded long-form tag IDs
high7.5Jul 21, 2026CVE-2026-59885
pyasn1: Quadratic complexity in OBJECT IDENTIFIER and RELATIVE-OID processing allows denial of service
high7.5Jul 21, 2026CVE-2026-59886
pyasn1: Uncontrolled resource consumption when converting decoded REAL values
high7.5Jul 21, 2026
