Skip to content

VNX-1241: Use of Predictable Algorithm in Random Number Generator

A java.util.Random, whose linear congruential algorithm is fully determined by its 48-bit seed, is given an explicit seed in production Java code.

Updated 05 Nov 2026Markdown
Field Value
Rule ID VNX-1241
Severity Medium
SARIF level warning
Kind sast
Languages Java
CWE CWE-1241
CAPEC CAPEC-66
ATT&CK T1190
CWSS vector CWSS:1.0/TI:M/AP:RU/AL:S/IC:N/FC:LT/RP:RU/RL:S/AV:L/AS:N/IN:A/SC:A/BI:M/DI:H/EX:M/EC:N/P:C
Tags predictable-rng java cwe-1241
Source internal/sast/rules/vnx-1241.rego

Overview

VNX-1241 maps to CWE-1241: Use of Predictable Algorithm in Random Number Generator.

Why this matters

java.util.Random is a 48-bit linear congruential generator. Its whole output follows from the seed, so a generator seeded with a constant, the clock or a value derived from user data produces values anyone can reproduce. Reset links, session ids and OTPs drawn from it can be predicted.

What gets flagged

private final Random rng = new Random(42L);
Random random = new Random(System.currentTimeMillis());
random.setSeed(key.length());      // random declared as java.util.Random

Not flagged: new Random() with no seed, SecureRandom and its setSeed, a method of your own named setSeed, test code.

Remediation

  1. Use java.security.SecureRandom for any value an attacker must not predict, and do not seed it yourself.
  2. Keep seeded java.util.Random for simulations and tests only.

References

Suppressing this rule

Put a nosec comment on the line, or on line 1 to cover the whole file. Use the comment marker of the file’s language (#, //, -- or ;):

# nosec vnx-1241
// nosec vnx-1241

Or record an ignore rule: vulnetix ignore add --rule vnx-1241 --reason "...". See Suppressing findings.

esc
↑ ↓ move↵ openSearches in your browser. A key like autonomy.max or a code like threshold_required jumps straight to it.