Severity by source
AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N
Network-reachable bignum input, no auth or UI, but AC:H because the victim app must both call checkPrime with default options and act on the result; cryptographic guarantees collapse so C:H/I:H, no availability impact.
Primary rating from Vendor (https://github.com/denoland/deno).
CVSS VectorVendor: https://github.com/denoland/deno
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N
Lifecycle Timeline
3DescriptionCVE.org
Summary
node:crypto.checkPrime(candidate[, options][, callback]) and crypto.checkPrimeSync(candidate[, options]) ran no Miller-Rabin rounds at all when the caller left options.checks at its default of 0. In that mode, the only test applied to the candidate was trial division by the primes up to 17,863. Any composite whose smallest prime factor exceeds that bound - for example the product of two primes just above it, such as 17,881 × 17,891 - was reported as true ("probably prime").
The same divergence affected the lower-level op_node_check_prime / op_node_check_prime_bytes paths that the polyfill calls into.
Node.js itself does not have this problem: it forwards checks = 0 to OpenSSL's BN_check_prime, which substitutes a sensible default number of rounds based on the candidate's bit length (per FIPS 186-4 Appendix C.3 Table C.1). Deno's Rust implementation had no equivalent fallback, so count = 0 meant "skip the loop entirely."
Affected APIs
crypto.checkPrime(candidate)(callback form, default options)crypto.checkPrime(candidate, { checks: 0 }, callback)crypto.checkPrimeSync(candidate)(default options)crypto.checkPrimeSync(candidate, { checks: 0 })
Callers who explicitly passed checks >= 1 were less affected, the loop ran the number of rounds they asked for, but were still receiving fewer rounds than Node would have applied for the same bit length. With the patched version they get at least the FIPS minimum.
Not affected
- Deno's prime *generation* (
crypto.generatePrime,crypto.generatePrimeSync, and the DH parameter generation path). Those routes go throughPrime::generate_with_optionsinext/node_crypto/primes.rs, which hardcodes20Miller-Rabin rounds and never reads a user-controlledchecksvalue, so the bug never reached them. - Any other Deno-internal use of primality testing -
is_probably_primeis not called from elsewhere in the runtime withcount = 0. - Web Crypto (
crypto.subtle.*), which uses entirely separate code paths and does not expose a primality test.
Impact
The realistic exposure is application-level: a Deno program that calls crypto.checkPrime (or its sync variant) with default options to validate an externally-supplied bignum, for example checking a peer-provided Diffie-Hellman prime, validating a prime read from configuration, or sanity-checking an RSA factor, will accept crafted composites as prime. The composite is trivial to construct: any product of two primes greater than 17,863 works.
Downstream consequences depend on what the program does with the "verified" prime. If the prime is fed into a key exchange, signature verification, or factorization-style check, the security guarantees of that protocol collapse to whatever the attacker engineered into the composite.
The CVSS impact is bounded by the requirement that the victim application both (a) calls checkPrime with default options and (b) acts on the result for security-relevant input it does not control.
Reproduction
import { checkPrimeSync } from "node:crypto";
// 17881 and 17891 are both prime and both above the trial-division
// ceiling used by Deno's implementation.
const composite = 17881n * 17891n;
// Affected versions print `true`; the patched version prints `false`.
console.log(checkPrimeSync(composite));The same result is reproducible from Rust against the internal helper:
use num_bigint::BigInt;
let composite = BigInt::from(17881u32) * BigInt::from(17891u32);
assert!(!is_probably_prime(&composite, 0)); // fails on affected versionsFix
PR #34391 introduces a helper min_miller_rabin_rounds_for_bits(bits) that returns the FIPS 186-4 Appendix C.3 round counts, matching the defaults OpenSSL uses inside BN_check_prime. is_probably_prime then clamps the loop bound to count.max(min_miller_rabin_rounds_for_bits(n.bits())). The probabilistic loop now always executes, regardless of what checks value the caller supplied, with a round count strong enough to keep the false-positive probability below 2^-80. Callers that pass a larger explicit checks still get exactly that many rounds.
Unit tests under ext/node_crypto/primes.rs cover the 17,881 × 17,891 case, a larger 64-bit composite, and the FIPS lookup table itself.
Workarounds
If you cannot upgrade immediately:
- Pass an explicit
checksvalue when callingcrypto.checkPrimeorcrypto.checkPrimeSync. A value of64is conservative for any reasonable bit length and keeps the loop running. - Do not rely on
crypto.checkPrimeto validate attacker-influenced bignums in security-critical paths until you are on the patched release.
Articles & Coverage 2
AnalysisAI
Cryptographic primality validation in Deno's Node.js compatibility layer (versions <= 2.8.0) silently skips Miller-Rabin testing when crypto.checkPrime/checkPrimeSync is called with default options, causing crafted composites whose smallest prime factor exceeds 17,863 (e.g. 17,881 × 17,891) to be reported as prime. Remote attackers who control bignums fed into a victim Deno application can therefore smuggle composite values past validation, with no public exploit identified at time of analysis beyond the vendor-published reproducer.
Technical ContextAI
The flaw lives in ext/node_crypto/primes.rs inside Deno's Rust implementation of the Node.js node:crypto polyfill. Node's upstream behavior forwards checks = 0 to OpenSSL's BN_check_prime, which transparently substitutes the FIPS 186-4 Appendix C.3 Table C.1 minimum round counts based on candidate bit length; Deno's is_probably_prime instead treated the user-supplied count as authoritative, so count == 0 produced an empty for _ in 0..count loop and the only remaining filter was trial division by the SMALL_PRIMES table (largest entry 17,863). This is a textbook CWE-325 (Missing Cryptographic Step) - the probabilistic primality test required for cryptographic correctness was omitted. Web Crypto (crypto.subtle) and Deno's prime *generation* paths (generatePrime, DH parameter generation) hardcode 20 rounds and are unaffected; the package identifier from CPE data is pkg:rust/deno.
RemediationAI
Vendor-released patch: Deno 2.8.1, which lands PR https://github.com/denoland/deno/pull/34391 introducing min_miller_rabin_rounds_for_bits and clamping the Miller-Rabin loop bound to at least the FIPS 186-4 Appendix C.3 minimum regardless of the caller-supplied checks value. If upgrading immediately is not possible, explicitly pass checks: 64 to every crypto.checkPrime/checkPrimeSync call (conservative for any reasonable bit length, with the trade-off of slightly higher CPU cost on large bignums), and audit code paths to ensure attacker-influenced bignums are not validated with checkPrime until you are on the patched release; treating untrusted DH primes or RSA factors as unverified is preferable to relying on the broken default. Full advisory and patch references: https://github.com/denoland/deno/security/advisories/GHSA-9xg4-qhm4-g43w and https://github.com/denoland/deno/pull/34391.
The (1) TLS and (2) DTLS implementations in OpenSSL 1.0.1 before 1.0.1g do not properly handle Heartbeat Extension packe
The dtls1_reassemble_fragment function in d1_both.c in OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0
OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph
The SSLv2 protocol, as used in OpenSSL before 1.0.1s and 1.0.2 before 1.0.2g and other products, requires a server to se
The ssl3_get_key_exchange function in s3_clnt.c in OpenSSL before 0.9.8zd, 1.0.0 before 1.0.0p, and 1.0.1 before 1.0.1k
The SSL protocol 3.0, as used in OpenSSL through 1.0.1i and other products, uses nondeterministic CBC padding, which mak
The AES-NI implementation in OpenSSL before 1.0.1t and 1.0.2 before 1.0.2h does not consider memory allocation during a
The X509_verify_cert function in crypto/x509/x509_vfy.c in OpenSSL 1.0.1n, 1.0.1o, 1.0.2b, and 1.0.2c does not properly
A buffer overrun can be triggered in X.509 certificate verification, specifically in name constraint checking. Rated hig
The ssl3_send_client_key_exchange function in s3_clnt.c in OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before
In OpenSSL 1.1.0 before 1.1.0d, if a malicious server supplies bad parameters for a DHE or ECDHE key exchange then this
A denial of service flaw was found in OpenSSL 0.9.8, 1.0.1, 1.0.2 through 1.0.2h, and 1.1.0 in the way the TLS/SSL proto
Same weakness CWE-325 – Missing Cryptographic Step
View allSame technique Information Disclosure
View allShare
External POC / Exploit Code
Leaving vuln.today
EUVD-2026-38540
GHSA-9xg4-qhm4-g43w