Skip to content

VNX-343: Predictable Value Range from Previous Values

Detects secrets that are the previous value plus a small random step (token += random.randint(...), session_id = last + rng.nextInt(500), isn = last_isn + (rand() % 64000)). Python, Java, Kotlin, JavaScript/TypeScript, PHP, Ruby, Go, C and C++.

Updated 02 Nov 2026Checked against cli@de9b52a
Field Value
Rule ID VNX-343
Severity Medium
SARIF level warning
Kind sast
Languages Python, Java, Kotlin, JavaScript / TypeScript, PHP, Ruby, Go, C, C++
CWE CWE-343
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 randomness predictable predictable-value-range cwe-343
Source internal/sast/rules/vnx-343.rego

Overview

VNX-343 maps to CWE-343: Predictable Value Range from Previous Values. A value that moves forward by a small random step from the last one is predictable within a window: anyone who has seen one value knows the next lies just above it, and tries the few hundred candidates. This is the classic weak TCP initial-sequence-number design, and it appears in hand-rolled token and session-id generators.

The rule reports:

  • x += <random draw> where x is named for a secret or an initial sequence number (token, session id, reset code, OTP, CSRF, password, API key, isn), and
  • <previous> + <random draw> where the previous value is named last/prev/previous/current/old/next or for a secret, and the sum is stored under, returned as, or flows within six lines into a secret.

A random draw is random.randint/randrange/getrandbits/uniform, secrets.randbelow, Math.random() (also inside Math.floor), rand()/mt_rand()/random_int(), nextInt/nextLong (Random, ThreadLocalRandom, kotlin.random.Random), Go rand.Intn/IntN/Int63n/Int31n (also inside a numeric conversion), Ruby rand/random_number, and C rand()/random()/arc4random_uniform. A small step from a CSPRNG is still reported: the range is the weakness, not the generator.

What Gets Flagged

# FLAGGED
self.last_token += random.randint(1, 1000)
reset_code = prev_code + random.randrange(10, 99)
session_id = last_session + secrets.randbelow(256)
// FLAGGED
long sessionId = previousSessionId + ThreadLocalRandom.current().nextInt(1, 500);
/* FLAGGED: initial sequence numbers a small step apart */
isn = last_isn + (rand() % 64000);
tcb->snd_isn += rand() & 0xffff;

What Is Not Flagged

  • Jitter, delays, backoff, poll intervals, positions, totals and other values that are not secrets (self.retry_delay += random.uniform(0, 1), next_poll = last_poll + random.randint(1, 5)).
  • Counts and bookkeeping names (token_count, session_timeout).
  • A draw written before the previous value (rand() + last), and an increment by a constant (VNX-342).
  • Test files, and the pattern in comments or string literals.

Remediation

  1. Generate each secret independently with a CSPRNG over its full width: secrets.token_urlsafe(), crypto.randomBytes(), random_bytes(), SecureRandom, crypto/rand.
  2. For sequence numbers, use a keyed hash of the connection identifiers plus a clock (RFC 6528) rather than a random step from the previous value.
  3. For confirmed false positives, add a # vulnetix-ignore: VNX-343 comment on the line.

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-343
// nosec vnx-343

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

Edit this pageSources: cli/internal/sast/rules/vnx-343.rego, cli/internal/sast/docs/vnx-343.md
esc
↑ ↓ move↵ openSearches in your browser. A key like autonomy.max or a code like threshold_required jumps straight to it.