CVE-2026-119197: pyasn1 has quadratic-complexity denial of service in binary REAL decoding
pyasn1 0.6.4 and earlier decode a binary ASN.1 REAL with a large mantissa in quadratic time. A REAL value of a few hundred thousand octets can hold a decoder worker for seconds in the BER, CER and DER decoders. Fixed in pyasn1 0.6.5.
Published Oct 30, 2026 · Analysis Oct 31, 2026
What an attacker can do
RealPayloadDecoder.valueDecoder in pyasn1/codec/ber/decoder.py builds the mantissa one octet at a time: it shifts an integer left by eight bits, ORs in chunk[0], and slices the chunk down by one byte. The integer grows with each step, and each slice copies the rest of the bytes, so total cost is quadratic in mantissa length. CER and DER reuse this decoder, so all three codecs hit the loop. The eight-octet length-field limit does not cap mantissa size in practice.
The work happens inside decode(). The application does not have to call float(), str() or prettyPrint() on the result. That separates it from CVE-2026-59886, which concerns converting an already-decoded REAL and was fixed in 0.6.4.
The reporter measured 0.328 s for a 50,000-octet mantissa and 24.095 s for 400,000 octets in BER. A 200,000-octet mantissa took 5.645 s through DER. Each doubling of input costs about four times as much. The loop is in every release tag checked, v0.2.1 through v0.6.4. The effect is CPU exhaustion only. Exposure depends on whether your application feeds attacker data containing REAL values (tag 0x09) to a decoder.
Who is affected
The pip package pyasn1, all versions <= 0.6.4, including releases as old as 0.2.1 per the advisory's code check. The risk applies when untrusted ASN.1 is decoded either without a schema or with a schema containing REAL. Check the installed version:
pip show pyasn1Downstream libraries that bundle or pin pyasn1 need the same check.
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 patch replaces the per-octet shift and slice loop with one int.from_bytes(bytes(chunk), "big") conversion, and keeps sign, scale, exponent and the decoded REAL tuple unchanged. Because it sits in the shared BER decoder, it covers BER, CER and DER. Before you can upgrade, reject or strictly limit untrusted ASN.1 that may contain REAL values, with a limit sized to your CPU budget and request volume.
How to tell if you were hit
Look for decode calls where the input carries a REAL (tag 0x09) with a very long length, for example 0x09 0x83 followed by a three-byte length in the hundreds of thousands. Watch for decoding threads that run for several seconds on single requests. A profile will show time in RealPayloadDecoder.valueDecoder. Run pip show pyasn1 over environments and container 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 binary-encoded ASN.1 REAL with a large mantissa can consume CPU time quadratic in the mantissa length. The BER, CER, and DER decoders all use the affected RealPayloadDecoder. An application is exposed when it passes attacker-controlled ASN.1 containing a REAL value to one of these decoders, either without an asn1Spec or with a schema that includes REAL. The work occurs inside decode(); the application does not need to convert, print, or otherwise use the resulting REAL object.
This is distinct from CVE-2026-59886, which concerns converting an already-decoded REAL to a Python float. That issue was fixed in 0.6.4 and its advisory states that decoding alone does not trigger it.
Root cause and affected components
For binary REAL values, `RealPayloadDecoder.valueDecoder` in v0.6.4 builds the mantissa one octet at a time:
p = 0
while chunk:
p <<= 8
p |= chunk[0]
chunk = chunk[1:]Each shift processes an integer that grows with the mantissa; with byte strings, each slice also copies the remaining suffix. Repeating both operations for every octet makes decoding quadratic in mantissa size. The decoder's eight-octet length-field limit does not impose a practical mantissa-size limit for the inputs demonstrated below. CER and DER reuse the BER REAL payload decoder, so all three paths reach this loop.
The vulnerable loop is present in every available repository release tag inspected, from v0.2.1 through v0.6.4. Runtime measurements below were made on v0.6.4; older releases were checked for the loop, not benchmarked individually.
Impact
A comparatively small REAL value can hold a decoder worker on one CPU core for seconds or longer. The attacker must be able to supply data that the application sends to an affected decoder, and application-level input limits may reduce exposure. The demonstrated effect is CPU exhaustion during decoding; this advisory does not assert a network endpoint, unauthenticated access, or an affected downstream application by itself.
Reproduction and evidence
The following example uses pyasn1 0.6.4. The 0x09 tag identifies REAL; 0x80 0x00 selects a positive, base-2 binary value with a one-octet zero exponent, followed by a large mantissa. It exercises decode() only.
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
def real_value(mantissa_octets):
content = b"\x80\x00" + b"\xff" * mantissa_octets
length = len(content).to_bytes(3, "big")
return b"\x09\x83" + length + content
for codec in (ber, cer, der):
for size in (50_000, 100_000, 200_000):
substrate = real_value(size)
started = time.process_time()
value, rest = codec.decode(substrate)
print(codec.__name__, size, time.process_time() - started)
assert not rest
assert tuple(value)[1:] == (2, 0)The original report measured the following BER CPU times on repository commit aa05757. That commit is later than the official v0.6.4 tag; the vulnerable loop is identical in the tagged release.
| Mantissa size | Reporter's BER CPU time | | 50,000 octets | 0.328 s | | 100,000 octets | 1.299 s | | 200,000 octets | 6.043 s | | 400,000 octets | 24.095 s |
The same report measured 5.645 s for a 200,000-octet mantissa through DER.
A separate local reproduction on the official v0.6.4 tag (d43496f, CPython 3.14.8, macOS arm64) measured BER at 0.209 s, 0.884 s, and 3.451 s for 50,000, 100,000, and 200,000 mantissa octets respectively. CER and DER each took about 0.89 s at 100,000 octets. These are machine-specific measurements; the repeated near-fourfold cost for doubled input is the relevant result. Neither reproduction calls float(), str(), or prettyPrint().
Fix
pyasn1 0.6.5 replaces the per-octet shift and slice loop with one int.from_bytes(bytes(chunk), "big") conversion. Sign, scale, exponent, and the decoded REAL tuple are preserved. The fix is in the shared BER payload decoder and therefore covers BER, CER, and DER. A local check of the 0.6.5 candidate decoded a 200,000-octet mantissa correctly through all three codecs; the check does not establish behavior for every application using REAL.
Workarounds
Upgrade to pyasn1 0.6.5. Until then, reject or strictly limit attacker-controlled ASN.1 input that may contain REAL values before passing it to pyasn1. The appropriate size limit depends on the application's available CPU time and request volume.
Credited to manus-use.
Questions
- Is pyasn1 0.6.4 affected by CVE-2026-119197?
Yes. The affected range is <= 0.6.4. Upgrade to 0.6.5.
- Does my app have to convert the REAL to a float to be hit?
No. The cost is paid inside decode(). No conversion, printing or other use of the decoded value is needed.
- Does DER protect against it?
No. CER and DER reuse the BER REAL payload decoder, so all three codecs reach the vulnerable loop.
- Is this the same as CVE-2026-59886?
No. That issue is about converting an already-decoded REAL to a Python float, and it was fixed in 0.6.4. This one is in decoding the mantissa, and needs 0.6.5.
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-119195
pyasn1 has quadratic-time denial of service in constructed string and indefinite-length ANY decoding
high7.5Oct 30, 2026CVE-2026-119196
pyasn1 has quadratic CPU consumption in constructed BIT STRING 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
