Listen to this Post
The vulnerability exists within the `crypto/rsa` library’s `NewPrivateKey` function. When constructing an RSA private key from its raw components (the primes P and Q, and the exponents), the function performs mathematical validation. A core requirement for RSA is that the primes are actual prime numbers greater than 1. The library contains checks to validate the provided components, including that P and Q are prime. However, if the input prime `P` or `Q` is explicitly set to the integer value 1, the validation logic triggers a division-by-zero condition when computing the modulus. In Go, this causes a runtime panic, abruptly crashing the application. This is a denial-of-service vulnerability because an attacker can provide a maliciously crafted key (with a prime set to 1) to any service that uses this API to parse external key data, causing the program to terminate unexpectedly instead of gracefully returning a standard error.
Platform: Go (golang) crypto/rsa
Version: Prior to patched versions
Vulnerability: RSA key panic
Severity: Critical
date: 2024-10-17
Prediction: Patch 2024-10-31
What Undercode Say:
$ cat malformed_key.go
import "crypto/rsa"
func main() {
// Constructing a key with a prime set to 1
badKey := &rsa.PrivateKey{
PublicKey: rsa.PublicKey{N: big.NewInt(0)},
D: big.NewInt(0),
Primes: []big.Int{big.NewInt(1), big.NewInt(3)}, // P=1
}
_, err := rsa.NewPrivateKey(badKey) // This call panics
}
How Exploit:
Attacker supplies a malformed RSA key to a TLS handshake, authentication endpoint, or any parsing service. Causes immediate process crash and denial-of-service.
Protection from this CVE
Update Go. Validate external keys before passing to NewPrivateKey. Use recover() in key parsing routines.
Impact:
Remote Denial-of-Service (panic). Availability loss.
🎯Let’s Practice Exploiting & Learn Patching For Free:
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

