CVE-2023-49083
NULL-pointer dereference in cryptography 41.0.5 load_pem_pkcs7_certificates and load_der_pkcs7_certificates functions
- CVSS 7.5
- CWE-476 NULL Pointer Dereference
- Design Defects
- Remote
cryptography is a package designed to expose cryptographic primitives and recipes to Python developers. Calling `load_pem_pkcs7_certificates` or `load_der_pkcs7_certificates` could lead to a NULL-pointer dereference and segfault. Exploitation of this vulnerability poses a serious risk of Denial of Service (DoS) for any application attempting to deserialize a PKCS7 blob/certificate. The consequences extend to potential disruptions in system availability and stability. This vulnerability has been patched in version 41.0.6.
- CVSS base score
- 7.5
- Published
- 2023-11-29
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Interface
- Code defect classification
- Extraneous Interface
- Category
- Design Defects
- Subcategory
- Inadequate Error Handling
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Fixed by upgrading
- Yes
Solution
Upgrade to version 41.0.6 of the cryptography package
Vulnerable code sample
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
def load_pkcs7_certificates(data):
certificates = serialization.load_pem_pkcs7_certificates(data, default_backend())
return certificates
pem_data = b"""-----BEGIN PKCS7-----\n...\n-----END PKCS7-----"""
certs = load_pkcs7_certificates(pem_data)
print("Certificates loaded:", certs)Patched code sample
from cryptography.hazmat.primitives import serialization
from cryptography.exceptions import UnsupportedAlgorithm
def load_pkcs7_certificates(data):
try:
if not data.startswith(b"-----BEGIN PKCS7-----"):
raise ValueError("Invalid PKCS7 format")
certificates = serialization.load_pem_pkcs7_certificates(data)
return certificates
except (ValueError, UnsupportedAlgorithm) as e:
return []
pem_data = b"""-----BEGIN PKCS7-----\nMIIB...FAKE...==\n-----END PKCS7-----"""
certs = load_pkcs7_certificates(pem_data)
print("Certificates loaded:", certs)Cite this entry
@misc{vaitp:cve202349083,
title = {{NULL-pointer dereference in cryptography 41.0.5 load_pem_pkcs7_certificates and load_der_pkcs7_certificates functions}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2023},
note = {VAITP Python Vulnerability Dataset, entry CVE-2023-49083},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-49083/}}
}
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 ::
