CVE-2012-2417: PyCrypto ElGamal Key Generation Vulnerability

pycrypto Updated 02 Oct 2025

Summary

17/06/2012
Yes i
Moderate
5.3

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 ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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 →

Share this vulnerability

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.

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback