CVE-2024-26130: cryptography NULL pointer deference with pkcs12.serialize_key_and_certificates when called with a non-matching certificate and private key and an hmac_hash override
cryptography is a package designed to expose cryptographic primitives and recipes to Python developers. Starting in version 38.0.0 and prior to version 42.0.4, if pkcs12.serializekeyandcertificates is called with both a certificate whose public key did not match the provided private key and an encryptionalgorithm with hmachash set (via PrivateFormat.PKCS12.encryptionbuilder().hmachash(...), then a NULL pointer dereference would occur, crashing the Python process. This has been resolved in version 42.0.4, the first version in which a ValueError is properly raised.
Other sources
cryptography is vulnerable to a denial of service, caused by a NULL pointer dereference in the pkcs12.serializekeyandcertificates process. By sending a specially crafted request, a remote attacker could exploit this vulnerability to cause a denial of service.
— IBM
If pkcs12.serializekeyandcertificates is called with both:
1. A certificate whose public key did not match the provided private key 2. An encryptionalgorithm with hmachash set (via PrivateFormat.PKCS12.encryptionbuilder().hmachash(...)
Then a NULL pointer dereference would occur, crashing the Python process.
This has been resolved, and now a ValueError is properly raised.
Patched in https://github.com/pyca/cryptography/pull/10423
— GitHub
If pkcs12.serializekeyandcertificates is called with both: - A certificate whose public key did not match the provided private key - An encryptionalgorithm with hmachash set (via PrivateFormat.PKCS12.encryptionbuilder().hmachash(...)
Then a NULL pointer dereference would occur, crashing the Python process. This has been resolved, and now a ValueError is properly raised.
Affected versions: >= 38.0.0, < 42.0.4
Patched in: https://github.com/pyca/cryptography/pull/10423
References: https://github.com/pyca/cryptography/security/advisories/GHSA-6vqw-3v5j-54x4 https://github.com/pyca/cryptography/pull/10423 https://github.com/pyca/cryptography/commit/97d231672763cdb5959a3b191e692a362f1b9e55
— Red Hat
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/python-cryptographyto a version that resolves this vulnerability.Fixed in 3.3.2-1Fixed in 3.3.2-1+deb11u1Fixed in 38.0.4-3+deb12u1Fixed in 43.0.0-1 - Upgrade
Upgrade
pip/cryptographyto a version that resolves this vulnerability.Fixed in 42.0.4 - Upgrade
Upgrade
redhat/cryptographyto a version that resolves this vulnerability.Fixed in 42.0.4 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 42.0.4Patch GHSA-6vqw-3v5j-54x4 - Compensating control
If you call pkcs12.serialize_key_and_certificates with both (1) a certificate whose public key did not match the provided private key and (2) an encryption_algorithm with hmac_hash set via PrivateFormat.PKCS12.encryption_builder().hmac_hash(...), avoid this combination or ensure the certificate public key matches the provided private key to prevent the NULL pointer dereference/DoS condition (affected in versions >= 38.0.0 and < 42.0.4).
Event History
Frequently Asked Questions
What is the severity of CVE-2024-26130?
CVE-2024-26130 has a moderate severity rating as it affects key serialization in cryptographic operations.
How do I fix CVE-2024-26130?
To fix CVE-2024-26130, upgrade the cryptography package to version 42.0.4 or later.
Which software versions are affected by CVE-2024-26130?
CVE-2024-26130 affects cryptography versions between 38.0.0 and 42.0.4, among others listed in the vulnerability report.
What are the potential impacts of CVE-2024-26130?
The potential impacts of CVE-2024-26130 include incorrect key serialization that may lead to vulnerabilities in cryptographic implementations.
Is there a specific vendor product impacted by CVE-2024-26130?
Yes, IBM's Storage Defender - Resiliency Service versions up to 2.0.9 are impacted by CVE-2024-26130.