cryptography vulnerable to NULL-dereference when loading PKCS7 certificates
Description
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.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Calling load_pem_pkcs7_certificates or load_der_pkcs7_certificates in the Python cryptography library before 41.0.6 can cause a NULL-pointer dereference and segfault, leading to a denial of service.
Vulnerability
Description
The Python cryptography library, which provides cryptographic primitives and recipes, contains a NULL-pointer dereference vulnerability in functions load_pem_pkcs7_certificates and load_der_pkcs7_certificates [1]. These functions are used to deserialize PKCS7 certificate bundles from PEM or DER formats. The flaw occurs when processing a PKCS7 blob that contains no certificates; the underlying OpenSSL code returns a NULL pointer in p7.d.sign, and prior to the fix, the library did not check for this condition before dereferencing the pointer [2][4].
Exploitation and
Attack Surface
An attacker can exploit this vulnerability by providing a specially crafted PKCS7 input (either PEM or DER) that triggers the NULL-pointer dereference. No authentication is required; the attack is entirely remote if an application accepts untrusted PKCS7 data. As demonstrated in the advisory, a minimal payload such as MAsGCSqGSIb3DQEHAg== (PEM) or its DER equivalent is sufficient to cause a crash [4]. Any Python application using these functions to load certificates from untrusted sources is vulnerable.
Impact
Successful exploitation results in a segmentation fault, leading to denial of service (DoS) [1]. This can disrupt system availability and stability, making the application unresponsive or terminating it entirely. The vulnerability is classified with a CVSS score of 7.5 (HIGH) due to its low attack complexity and network-based vector causing complete availability impact.
Mitigation
Status
The vulnerability has been patched in cryptography version 41.0.6, released on 2023-11-27 [1][2][3]. The fix adds a NULL check on p7.d.sign before accessing its cert member, returning an empty list if the pointer is NULL [3]. All users should upgrade to version 41.0.6 or later. There are no known workarounds; applications that cannot upgrade should avoid processing untrusted PKCS7 input.
AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
cryptographyPyPI | >= 3.1, < 41.0.6 | 41.0.6 |
Affected products
26- osv-coords25 versionspkg:apk/chainguard/mitmproxypkg:apk/chainguard/py3-cassandra-medusapkg:apk/chainguard/py3-cassandra-medusa-compatpkg:apk/wolfi/mitmproxypkg:apk/wolfi/py3-cassandra-medusapkg:apk/wolfi/py3-cassandra-medusa-compatpkg:pypi/cryptographypkg:rpm/almalinux/python3.11-cryptographypkg:rpm/almalinux/python3-cryptographypkg:rpm/opensuse/python3-cryptography&distro=openSUSE%20Leap%2015.4pkg:rpm/opensuse/python3-cryptography&distro=openSUSE%20Leap%2015.5pkg:rpm/opensuse/python3-cryptography&distro=openSUSE%20Leap%20Micro%205.3pkg:rpm/opensuse/python3-cryptography&distro=openSUSE%20Leap%20Micro%205.4pkg:rpm/opensuse/python-cryptography&distro=openSUSE%20Leap%2015.4pkg:rpm/opensuse/python-cryptography&distro=openSUSE%20Leap%2015.5pkg:rpm/suse/python3-cryptography&distro=SUSE%20Linux%20Enterprise%20Micro%205.3pkg:rpm/suse/python3-cryptography&distro=SUSE%20Linux%20Enterprise%20Micro%205.4pkg:rpm/suse/python3-cryptography&distro=SUSE%20Linux%20Enterprise%20Micro%205.5pkg:rpm/suse/python3-cryptography&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP4pkg:rpm/suse/python3-cryptography&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP5pkg:rpm/suse/python-cryptography&distro=SUSE%20Linux%20Enterprise%20Micro%205.1pkg:rpm/suse/python-cryptography&distro=SUSE%20Linux%20Enterprise%20Micro%205.2pkg:rpm/suse/python-cryptography&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Public%20Cloud%2015%20SP1pkg:rpm/suse/python-cryptography&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Python%203%2015%20SP4pkg:rpm/suse/python-cryptography&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Python%203%2015%20SP5
< 12.2.1-r0+ 24 more
- (no CPE)range: < 12.2.1-r0
- (no CPE)range: < 0.19.1-r1
- (no CPE)range: < 0.19.1-r1
- (no CPE)range: < 12.2.1-r0
- (no CPE)range: < 0.19.1-r1
- (no CPE)range: < 0.19.1-r1
- (no CPE)range: >= 3.1, < 41.0.6
- (no CPE)range: < 37.0.2-6.el9
- (no CPE)range: < 3.2.1-8.el8_10
- (no CPE)range: < 3.3.2-150400.23.1
- (no CPE)range: < 3.3.2-150400.23.1
- (no CPE)range: < 3.3.2-150400.23.1
- (no CPE)range: < 3.3.2-150400.23.1
- (no CPE)range: < 41.0.3-150400.16.12.1
- (no CPE)range: < 41.0.3-150400.16.12.1
- (no CPE)range: < 3.3.2-150400.23.1
- (no CPE)range: < 3.3.2-150400.23.1
- (no CPE)range: < 3.3.2-150400.23.1
- (no CPE)range: < 3.3.2-150400.23.1
- (no CPE)range: < 3.3.2-150400.23.1
- (no CPE)range: < 3.3.2-150200.22.1
- (no CPE)range: < 3.3.2-150200.22.1
- (no CPE)range: < 3.3.2-150100.7.18.1
- (no CPE)range: < 41.0.3-150400.16.12.1
- (no CPE)range: < 41.0.3-150400.16.12.1
- pyca/cryptographyv5Range: >= 3.1, < 41.0.6
Patches
1f09c261ca10a41.0.6 release (#9927)
9 files changed · +26 −5
CHANGELOG.rst+9 −0 modified@@ -1,6 +1,15 @@ Changelog ========= +.. _v41-0-6: + +41.0.6 - 2023-11-27 +~~~~~~~~~~~~~~~~~~~ + +* Fixed a null-pointer-dereference and segfault that could occur when loading + certificates from a PKCS#7 bundle. Credit to **pkuzco** for reporting the + issue. **CVE-2023-49083** + .. _v41-0-5: 41.0.5 - 2023-10-24
docs/spelling_wordlist.txt+1 −0 modified@@ -38,6 +38,7 @@ decrypted decrypting deprecations DER +dereference deserialize deserialized Deserialization
pyproject.toml+1 −1 modified@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta" [project] name = "cryptography" -version = "41.0.5" +version = "41.0.6" authors = [ {name = "The Python Cryptographic Authority and individual contributors", email = "cryptography-dev@python.org"} ]
src/cryptography/__about__.py+1 −1 modified@@ -10,7 +10,7 @@ "__copyright__", ] -__version__ = "41.0.5" +__version__ = "41.0.6" __author__ = "The Python Cryptographic Authority and individual contributors"
src/cryptography/hazmat/backends/openssl/backend.py+4 −1 modified@@ -1890,9 +1890,12 @@ def _load_pkcs7_certificates(self, p7) -> typing.List[x509.Certificate]: _Reasons.UNSUPPORTED_SERIALIZATION, ) + certs: list[x509.Certificate] = [] + if p7.d.sign == self._ffi.NULL: + return certs + sk_x509 = p7.d.sign.cert num = self._lib.sk_X509_num(sk_x509) - certs = [] for i in range(num): x509 = self._lib.sk_X509_value(sk_x509, i) self.openssl_assert(x509 != self._ffi.NULL)
src/rust/src/lib.rs+2 −0 modified@@ -3,6 +3,8 @@ // for complete details. #![deny(rust_2018_idioms)] +// Work-around for https://github.com/PyO3/pyo3/issues/3561 +#![allow(unknown_lints, clippy::unnecessary_fallible_conversions)] mod asn1; mod backend;
tests/hazmat/primitives/test_pkcs7.py+6 −0 modified@@ -89,6 +89,12 @@ def test_load_pkcs7_unsupported_type(self, backend): mode="rb", ) + def test_load_pkcs7_empty_certificates(self, backend): + der = b"\x30\x0B\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x07\x02" + + certificates = pkcs7.load_der_pkcs7_certificates(der) + assert certificates == [] + # We have no public verification API and won't be adding one until we get # some requirements from users so this function exists to give us basic
vectors/cryptography_vectors/__about__.py+1 −1 modified@@ -6,4 +6,4 @@ "__version__", ] -__version__ = "41.0.5" +__version__ = "41.0.6"
vectors/pyproject.toml+1 −1 modified@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "cryptography_vectors" -version = "41.0.5" +version = "41.0.6" authors = [ {name = "The Python Cryptographic Authority and individual contributors", email = "cryptography-dev@python.org"} ]
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
10- github.com/advisories/GHSA-jfhm-5ghh-2f97ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2023-49083ghsaADVISORY
- www.openwall.com/lists/oss-security/2023/11/29/2ghsaWEB
- github.com/pyca/cryptography/commit/f09c261ca10a31fe41b1262306db7f8f1da0e48aghsax_refsource_MISCWEB
- github.com/pyca/cryptography/pull/9926ghsax_refsource_MISCWEB
- github.com/pyca/cryptography/security/advisories/GHSA-jfhm-5ghh-2f97ghsax_refsource_CONFIRMWEB
- github.com/pypa/advisory-database/tree/main/vulns/cryptography/PYSEC-2023-254.yamlghsaWEB
- lists.debian.org/debian-lts-announce/2024/10/msg00012.htmlghsaWEB
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/QMNTYMUGFJSDBYBU22FUYBHFRZODRKXVghsaWEB
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/QMNTYMUGFJSDBYBU22FUYBHFRZODRKXV/mitre
News mentions
0No linked articles in our index yet.