CVE-2012-2417: PyCrypto ElGamal Key Generation Vulnerability
Summary
CVE-2012-2417: PyCrypto before 2.6 does not produce appropriate prime numbers when using an ElGamal scheme to generate a key, which reduces the signature space or public key space and makes it easier for attackers to conduct brute forc... Affects pycrypto across 2 version ranges.
< 2.6
< 9f912f13df99ad3421eff360d6a62d7dbec755c2
Fixed in 9f912f13df99ad3421eff360d6a62d7dbec755c2. How to fix ↓
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
PyCrypto is a Python library that provides cryptographic services such as encryption, decryption, and key generation. It is widely used in various applications to secure sensitive data. The ElGamal scheme is one of the key generation algorithms supported by PyCrypto. This vulnerability affects PyCrypto versions prior to 2.6 and specifically impacts the generation of prime numbers in the ElGamal key generation process.
Vulnerability Detail
The vulnerability in PyCrypto's ElGamal key generation process results in the production of inappropriate prime numbers. This flaw reduces the signature space or public key space, making it easier for attackers to conduct brute force attacks and potentially obtain the private key. By exploiting this vulnerability, an attacker could compromise the confidentiality and integrity of encrypted data, as well as impersonate the legitimate owner of the private key.
How To Fix
Latest published version: 2.6.1 as of 22 Oct 2026
pip install --upgrade "pycrypto==2.6.1"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
9f912f13df99ad3421eff360d6a62d7dbec755c2
This is the first release that contains the fix.
pip install --upgrade "pycrypto==9f912f13df99ad3421eff360d6a62d7dbec755c2"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
There is no known workaround for this vulnerability. It is essential to upgrade to the fixed version of PyCrypto to mitigate the risk effectively.
Conclusion
The PyCrypto ElGamal key generation vulnerability poses a significant risk to the security of cryptographic operations. It is crucial to upgrade to PyCrypto version 2.6 or later to address this vulnerability and ensure the confidentiality and integrity of sensitive data. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for pycrypto →
FAQ
PyCrypto is a Python library that provides cryptographic services such as encryption, decryption, and key generation.
The ElGamal scheme is a public-key cryptosystem that is based on the Diffie-Hellman key exchange protocol. It is used for encryption, digital signatures, and key generation.
This vulnerability reduces the security of the ElGamal key generation process in PyCrypto, making it easier for attackers to conduct brute force attacks and potentially obtain the private key.
To fix this vulnerability, you should upgrade PyCrypto to version 2.6 or later.
No, there is no known workaround for this vulnerability. Upgrading to the fixed version of PyCrypto is the recommended solution.
Related vulnerabilities
Recent vulnerabilities recorded for pycrypto.