CVE-2026-49440: Deno: Miller-Rabin Primality Test Allows Zero Rounds

Published Jun 16, 2026
·
Updated

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 opnodecheckprime / opnodecheckprimebytes paths that the polyfill calls into.

Node.js itself does not have this problem: it forwards checks = 0 to OpenSSL's BNcheckprime, 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 through Prime::generatewithoptions in ext/nodecrypto/primes.rs, which hardcodes 20 Miller-Rabin rounds and never reads a user-controlled checks value, so the bug never reached them. - Any other Deno-internal use of primality testing — isprobablyprime is not called from elsewhere in the runtime with count = 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

ts 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:

rust use numbigint::BigInt; let composite = BigInt::from(17881u32) BigInt::from(17891u32); assert!(!isprobablyprime(&composite, 0)); // fails on affected versions

Fix

PR #34391 introduces a helper minmillerrabinroundsforbits(bits) that returns the FIPS 186-4 Appendix C.3 round counts, matching the defaults OpenSSL uses inside BNcheckprime. isprobablyprime then clamps the loop bound to count.max(minmillerrabinroundsforbits(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/nodecrypto/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 checks value when calling crypto.checkPrime or crypto.checkPrimeSync. A value of 64 is conservative for any reasonable bit length and keeps the loop running. - Do not rely on crypto.checkPrime to validate attacker-influenced bignums in security-critical paths until you are on the patched release.

Other sources

Deno is a JavaScript, TypeScript, and WebAssembly runtime. Prior to 2.8.1, 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 opnodecheckprime / opnodecheckprimebytes paths that the polyfill calls into. This vulnerability is fixed in 2.8.1.

— MITRE

Affected Software

2 affected componentsFixes available
rust/deno<=2.8.0
2.8.1
Deno Deno<2.8.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade rust/deno to a version that resolves this vulnerability.

    Fixed in 2.8.1
  2. Upgrade

    Upgrade Deno to a version that resolves this vulnerability.

    Fixed in 2.8.1
  3. Configuration

    When calling `crypto.checkPrime(candidate, options)` or `crypto.checkPrimeSync(candidate, options)`, pass an explicit `checks` value (do not use the default `checks: 0`) so Miller-Rabin runs are not skipped.

    node:crypto (Deno implementation of checkPrime/checkPrimeSync) options.checks = >= 1
  4. Compensating control

    If you cannot upgrade immediately, do not rely on `crypto.checkPrime` / `crypto.checkPrimeSync` with default options to validate attacker-influenced bignums in security-critical paths; treat the result as untrusted unless you pass explicit `checks >= 1`.

Event History

Jun 16, 2026
Advisory Published
via GitHub·07:08 PM
Data Sourced
via GitHub·07:08 PM
DescriptionSeverityWeaknessAffected Software
Jun 23, 2026
CVE Published
via MITRE·05:13 PM
Data Sourced
via MITRE·05:13 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·06:18 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2026-49440?

The severity of CVE-2026-49440 is high with a score of 7.4.

2

How do I fix CVE-2026-49440?

To fix CVE-2026-49440, update your version of Rust or Deno to the latest stable release that addresses this vulnerability.

3

What software is affected by CVE-2026-49440?

CVE-2026-49440 affects the Rust and Deno programming environments.

4

What problem does CVE-2026-49440 create?

CVE-2026-49440 allows potential attacks through inadequate prime checking, as it skips necessary Miller-Rabin rounds.

5

What is the default behavior of checkPrime in CVE-2026-49440?

In CVE-2026-49440, the default behavior of checkPrime is to only perform trial division by the lowest primes if 'options.checks' is set to its default of 0.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203