CVE-2016-9243: Vulnerability in cryptography package
Summary
CVE-2016-9243: HKDF in cryptography before 1.5.2 returns an empty byte-string if used with a length less than algorithm.digest_size. Affects cryptography across 2 version ranges.
< 1.5.3
< b924696b2e8731f39696584d12cceeb3aeb2d874
Fixed in b924696b2e8731f39696584d12cceeb3aeb2d874. How to fix ↓
Also tracked for
- python-cryptography · Debian:11
The same CVE-2016-9243 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The cryptography package is a Python library that provides cryptographic recipes and primitives. It is widely used for secure communication, data storage, and authentication. The package includes various algorithms and protocols for encryption, hashing, key derivation, and more. However, versions before 1.5.2 of cryptography are vulnerable to an issue in the HKDF (HMAC-based Extract-and-Expand Key Derivation Function) implementation.
Vulnerability Detail
The vulnerability (CVE-2016-9243) in cryptography before version 1.5.2 occurs when using HKDF with a length less than the algorithm's digest size. In such cases, the function returns an empty byte-string instead of the expected derived key. This behavior can lead to unexpected results and security weaknesses in applications that rely on HKDF for key derivation. Attackers may exploit this vulnerability to bypass security measures or gain unauthorized access to sensitive information.
How To Fix
Latest published version: 50.0.2 as of 22 Oct 2026
pip install --upgrade "cryptography==50.0.2"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
b924696b2e8731f39696584d12cceeb3aeb2d874
This is the first release that contains the fix.
pip install --upgrade "cryptography==b924696b2e8731f39696584d12cceeb3aeb2d874"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating the cryptography package is not immediately feasible, a possible workaround is to manually check the length of the derived key and handle the empty byte-string case appropriately in the application code. Here is an example in Python:
import cryptography.hazmat.primitives.kdf.hkdf as hkdf
# Perform HKDF key derivation
kdf = hkdf.HKDF(
algorithm=hkdf.HASH_ALGORITHMS.SHA256,
length=32,
salt=None,
info=b'',
backend=default_backend()
)
key_material = kdf.derive(secret)
# Check if derived key is empty
if len(key_material) == 0:
# Handle empty key case
...
else:
# Use the derived key
...
This workaround ensures that the application handles the empty byte-string case and avoids potential issues caused by the vulnerability.
Conclusion
The vulnerability in the cryptography package (CVE-2016-9243) can be fixed by updating to version 1.5.2 or later. It is important to promptly address this vulnerability to ensure the security of applications that rely on HKDF for key derivation. For further support on vulnerability remediation, you can contact DevNack.com.
See every vulnerability recorded for cryptography →
FAQ
The cryptography package is a Python library that provides cryptographic recipes and primitives for secure communication, data storage, and authentication.
HKDF (HMAC-based Extract-and-Expand Key Derivation Function) is a key derivation function that uses a cryptographic hash function to derive keys of arbitrary length from a master key.
The vulnerability in cryptography can lead to unexpected results and security weaknesses in applications that rely on HKDF for key derivation. Attackers may exploit this vulnerability to bypass security measures or gain unauthorized access to sensitive information.
To fix this vulnerability, update the cryptography package to version 1.5.2 or later using the package manager of your Python environment, such as pip.
If updating the cryptography package is not immediately feasible, you can manually check the length of the derived key and handle the empty byte-string case appropriately in your application code.
References
Related vulnerabilities
Recent vulnerabilities recorded for cryptography.