VYPR
Unrated severityNVD Advisory· Published Sep 6, 2021· Updated Jun 9, 2025

CVE-2021-40528

CVE-2021-40528

Description

Libgcrypt ElGamal before 1.9.4 allows plaintext recovery via cross-configuration attacks when interacting with other OpenPGP implementations.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Libgcrypt ElGamal before 1.9.4 allows plaintext recovery via cross-configuration attacks when interacting with other OpenPGP implementations.

Vulnerability

A cross-configuration attack exists in the ElGamal encryption implementation in Libgcrypt versions before 1.9.4. During interaction between two different OpenPGP libraries (e.g., Libgcrypt and Crypto++), a dangerous combination of the receiver's public key parameters (prime and generator) and the sender's ephemeral exponents can lead to plaintext recovery from a single ciphertext. This occurs because different libraries have ambiguous interpretations of the OpenPGP standard, leading to insecure parameter combinations that are not secure when used across implementations [1][2].

Exploitation

An attacker can exploit this by obtaining a ciphertext generated by a sender using one library (e.g., Libgcrypt) where the receiver's public key was created by another library (e.g., Crypto++). The attacker observes the ciphertext and the receiver's public key, then uses the specific parameter mismatch to recover the plaintext. No authentication or user interaction is required beyond capturing the encrypted message [1][2].

Impact

Successful exploitation allows an attacker to recover the plaintext of a single captured ciphertext. This compromises the confidentiality of encrypted communications. The attack is practical and has been demonstrated with real-world keys; over 2000 vulnerable public keys were identified [1].

Mitigation

The vulnerability is fixed in Libgcrypt version 1.9.4, released in 2021. Users should upgrade to this version or later. There is no known workaround [4]. Systems using OpenPGP are advised to ensure all components are updated to compatible versions that avoid cross-configuration issues [1][2][3].

AI Insight generated on May 25, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

4

Patches

0

No patches discovered yet.

Vulnerability mechanics

Root cause

"Cross-configuration mismatch: Libgcrypt uses Lim–Lee primes with a full-group generator and short ephemeral exponents, while other libraries use safe primes with a subgroup generator, enabling an attacker to compute the ephemeral secret via Pohlig–Hellman and recover the plaintext from a single ciphertext."

Attack vector

An attacker observes a single ElGamal ciphertext (Y, Z) produced by a sender using Libgcrypt (or a library with similar short-exponent, full-group-generator behavior) that was encrypted under a recipient's public key whose prime p–1 has small factors (e.g., a DSA-like or quasi-safe prime). Because the sender's ephemeral exponent y is short (≈344 bits for a 2048-bit p) and g generates the full group of order p–1, the attacker can apply Pohlig–Hellman to compute y modulo each small factor of p–1, then combine results via CRT and recover y with Baby-step giant-step. With y known, the attacker computes the shared secret X^y = Y^x and decrypts M = Z / X^y mod p. The attack requires no chosen ciphertexts, no side channel, and only one intercepted ciphertext [ref_id=1].

Affected code

The vulnerability is in Libgcrypt's ElGamal implementation, which generates Lim–Lee primes, uses a full-group generator g (smallest integer ≥ 2 that generates the full group), and draws the ephemeral exponent y from a short interval (≈344 bits for a 2048-bit p). The specific functions are not named in the advisory, but the parameter choices are described in detail [ref_id=1].

What the fix does

The advisory does not include a patch diff, but the CVE description states the fix is in Libgcrypt before 1.9.4. The recommended remediation is to ensure that the ephemeral exponent y is sampled uniformly from the full range [1, p–1] (as the Go standard library does) or at least from an interval large enough to resist Pohlig–Hellman combined with Baby-step giant-step. Additionally, implementations should validate that the received public key's group order has no small factors or, alternatively, restrict the generator to a prime-order subgroup to eliminate the small-subgroup attack surface [ref_id=1].

Preconditions

  • networkAttacker must intercept a single ElGamal ciphertext (Y, Z) in transit.
  • configSender's library uses short ephemeral exponents and a full-group generator (e.g., Libgcrypt before 1.9.4).
  • configRecipient's public key uses a prime p where p–1 has small factors (e.g., DSA-like or quasi-safe primes).

Generated on May 26, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

5

News mentions

0

No linked articles in our index yet.