GHSA-fm9c-5rcf-2q5p: pyasn1 has quadratic CPU use in schemaless BER/CER/DER container decoding

  • Severity: HIGH
  • CVE: CVE-2026-119194
  • Ecosystems: pip
  • Packages: pyasn1

### Summary

When an application decodes attacker-controlled BER, CER, or DER data without an ASN.1 schema, a container with many distinct long tag IDs can cause quadratic CPU use. Repeated inputs can exhaust CPU and reduce service availability.

### Details

ConstructedPayloadDecoderBase._decodeComponentsSchemaless inserts every decoded component’s TagSet into a growing set, although it only needs to distinguish one tag set from two or more. Attacker-chosen tag IDs can have colliding TagSet hashes, making each later insertion compare against an increasing number of earlier tags. This path is present in v0.6.4 and is inherited by the CER and DER decoders. The proposed fix stops growing the classification set after it contains two distinct tag sets, while retaining every decoded component and its order. On v0.6.4 with CPython 3.12.10, increasing the collision input from 3,200 to 6,400 components raised decode CPU time from 0.438 to 1.747 seconds; a comparable control rose from 0.031 to 0.065 seconds. Both inputs decoded successfully with the expected values and an empty remainder.

### Proof of concept

Run this outside the repository checkout in a fresh Python 3.12 environment with pyasn1==0.6.4 installed:

“`python
import sys
import time

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

def enc_tag(tag_id):
groups = [tag_id & 0x7f]
tag_id >>= 7
while tag_id:
groups.append((tag_id & 0x7f) | 0x80)
tag_id >>= 7
return b’\xbf’ + bytes(reversed(groups))…

Source: GitHub Security Advisories · 2026-10-30