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.serialize_key_and_certificates` is called with both a certificate whose public key did not match the provided private key and an `encryption_algorithm` with `hmac_hash` set (via `PrivateFormat.PKCS12.encryption_builder().hmac_hash(...)`, 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.
- Products
- Not specified
- Affected versions
- Not specified
- Fixed versions
- Not specified
- CVEs
- CVE-2024-26130
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 5 Nov 2026, 02:09 UTC · Revision 1
Source evidence
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
core-osv · Original sourcePublished 21 Feb 2024, 16:28 UTC
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.serialize_key_and_certificates` is called with both a certificate whose public key did not match the provided private key and an `encryption_algorithm` with `hmac_hash` set (via `PrivateFormat.PKCS12.encryption_builder().hmac_hash(...)`, 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.
osv:CVE-2024-26130
Complete source record
{
"id": "3a412b44fbc70665e0f394e82f3b636471b15c2ac30ae7d5e61dcfcbfa171111",
"url": "https://osv.dev/vulnerability/CVE-2024-26130",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "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",
"summary": "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.serialize_key_and_certificates` is called with both a certificate whose public key did not match the provided private key and an `encryption_algorithm` with `hmac_hash` set (via `PrivateFormat.PKCS12.encryption_builder().hmac_hash(...)`, 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.",
"evidence": "osv:CVE-2024-26130",
"products": [],
"severity": "high",
"structured": {
"id": "CVE-2024-26130",
"aliases": [
"CVE-2024-26130",
"GHSA-6vqw-3v5j-54x4",
"PYSEC-2024-225"
],
"metrics": [
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
}
],
"affected": [
{
"ranges": [
{
"repo": "https://github.com/pyca/cryptography",
"type": "GIT",
"events": [
{
"introduced": "52d6f1a491f6ade379ace124b843ffba9fb4ab4f"
},
{
"fixed": "fe18470f7d05f963e7267e34fdf985d81ea6ceea"
},
{
"fixed": "97d231672763cdb5959a3b191e692a362f1b9e55"
}
],
"database_specific": {
"extracted_events": [
{
"cpe": "cpe:2.3:a:cryptography.io:cryptography:*:*:*:*:*:python:*:*",
"range": [
{
"introduced": "38.0.0"
},
{
"fixed": "42.0.4"
}
],
"source": "CPE_RANGE"
},
{
"range": [
{
"fixed": "97d231672763cdb5959a3b191e692a362f1b9e55"
}
],
"source": "REFERENCES_COMMIT"
}
]
}
}
],
"versions": [
"42.0.3",
"42.0.2",
"42.0.1",
"42.0.0",
"41.0.0",
"40.0.0",
"39.0.0",
"38.0.0"
],
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-26130.json"
}
}
],
"modified": "2026-10-28T02:30:41.775056295Z",
"provider": "osv",
"references": [
"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/26xxx/CVE-2024-26130.json",
"https://github.com/pyca/cryptography/security/advisories/GHSA-6vqw-3v5j-54x4",
"https://nvd.nist.gov/vuln/detail/CVE-2024-26130",
"https://github.com/pyca/cryptography/commit/97d231672763cdb5959a3b191e692a362f1b9e55",
"https://github.com/pyca/cryptography/pull/10423"
],
"provider_metadata": {
"cwe_ids": [
"CWE-476"
],
"cna_assigner": "GitHub_M",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/26xxx/CVE-2024-26130.json"
}
},
"related_cves": [
{
"value": "CVE-2024-26130",
"evidence": "/id"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 509389,
"published_at": "2024-02-21T16:28:18.632+00:00"
}