VAITP Dataset

← Back to the dataset

CVE-2026-119196

Quadratic CPU consumption decoding crafted BIT STRING fragments in pyasn1

  • CVSS 7.5
  • CWE-407
  • Resource Management
  • Remote

pyasn1 is a generic ASN.1 library for Python. Prior to 0.6.5, constructed BIT STRING decoding repeatedly shifts and copies the complete bit value accumulated from earlier fragments. Attacker-controlled BER or CER input contains many constructed BIT STRING fragments; schema-driven DER also accepts a definite-length constructed BIT STRING. BitStringPayloadDecoder repeatedly calls BitString.fromOctetString with the prior bitString as prepend, shifting an ever-growing SizedInteger for each fragment and causing quadratic work. Large fragmented values can exhaust CPU during decode() without requiring later conversion or formatting. This issue is fixed in version 0.6.5.

CVSS base score
7.5
Published
2026-10-29
OWASP
A04 Insecure Design
Orthogonal defect classification
Algorithm
Code defect classification
Incorrect Algorithm
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
pyasn1
Fixed by upgrading
Yes

Solution

Upgrade pyasn1 to version 0.6.5 or later.

Vulnerable code sample

from pyasn1.type import univ
from pyasn1.codec.ber import decoder

def decode_fragments(encoded_bytes):
    # VULNERABLE: quadratic copy while concatenating fragments
    bit_str = univ.BitString()
    rest = encoded_bytes
    while rest:
        fragment, rest = decoder.decode(rest, asn1Spec=univ.BitString())
        # each iteration copies the whole accumulated value
        bit_str = univ.BitString.fromOctetString(bit_str.asOctets() + fragment.asOctets())
    return bit_str

Patched code sample

from pyasn1.type import univ
from pyasn1.codec.ber import decoder

def decode_fragments(encoded_bytes):
    # FIX: accumulate fragments in a list and concatenate once
    parts = []
    rest = encoded_bytes
    while rest:
        fragment, rest = decoder.decode(rest, asn1Spec=univ.BitString())
        parts.append(fragment.asOctets())
    combined = b''.join(parts)
    return univ.BitString.fromOctetString(combined)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve2026119196,
  title        = {{Quadratic CPU consumption decoding crafted BIT STRING fragments in pyasn1}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-119196},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-119196/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.