CVE-2019-14859
Python-ecdsa < 0.13.3 accepted malformed signatures, enabling false transactions
- CVSS 9.1
- CWE-347 Improper Verification of Cryptographic Signature
- Input Validation and Sanitization
- Remote
A flaw was found in all python-ecdsa versions before 0.13.3, where it did not correctly verify whether signatures used DER encoding. Without this verification, a malformed signature could be accepted, making the signature malleable. Without proper verification, an attacker could use a malleable signature to create false transactions.
- CVSS base score
- 9.1
- Published
- 2020-01-02
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Incorrect Check
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Unauthorized Access
- Fixed by upgrading
- Yes
Solution
Update python-ecdsa to version 0.13.3 or higher.
Vulnerable code sample
from ecdsa import SigningKey, VerifyingKey, BadSignatureError
def verify_signature(signature, message, public_key):
try:
if public_key.verify(signature, message):
print("Signature is valid.")
else:
raise BadSignatureError("Signature verification failed.")
except BadSignatureError:
print("Signature verification failed.")
private_key = SigningKey.generate()
public_key = private_key.get_verifying_key()
message = b"Sample message"
signature = private_key.sign(message)
verify_signature(signature, message, public_key)Patched code sample
from ecdsa import SigningKey, VerifyingKey, BadSignatureError
from ecdsa.util import string_to_number, number_to_string
from ecdsa.der import der_decode
def verify_signature(der_signature, message, public_key):
try:
r, s = der_decode(der_signature)
if not public_key.verify((r, s), message):
raise BadSignatureError("Signature verification failed.")
except Exception as e:
raise BadSignatureError("Invalid signature format or verification failed.") from e
private_key = SigningKey.generate()
public_key = private_key.get_verifying_key()
message = b"Sample message"
signature = private_key.sign(message)
try:
verify_signature(signature, message, public_key)
print("Signature is valid.")
except BadSignatureError as e:
print(f"Signature verification failed: {e}")Cite this entry
@misc{vaitp:cve201914859,
title = {{Python-ecdsa < 0.13.3 accepted malformed signatures, enabling false transactions}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2020},
note = {VAITP Python Vulnerability Dataset, entry CVE-2019-14859},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-14859/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
