CWE-343, Predictable Value Range from Previous Values, is a random number generator whose observed series can be used to infer a relatively small range of possibilities for the next value.
It is the partial cousin of CWE-342. The attacker cannot name the next value, but can narrow the guess.
How it happens
MITRE gives a clear example. Suppose a product generates numbers between 1 and 100, but always produces a larger value until it reaches 100. After observing a few outputs, the attacker knows the next one is above the last. The output of a generator should not be predictable from observation of previous values.
# Vulnerable: value only ever climbs
last = min(100, last + random.randint(1, 5))
The record lists no observed CVEs for this entry.
What an attacker gains
The record lists impact as varying by context. A narrowed range reduces the effort of a brute force attack on tokens or codes.
How to find it
No detection method is listed. Sample a long run of outputs and look for trends, such as steadily rising values or clusters.
How to fix it
MITRE's mitigations:
- Increase the entropy used to seed a PRNG.
- Use modules that conform to FIPS 140-2, and consult its approved generator list.
- Use a PRNG that periodically re-seeds itself from high quality sources, without re-seeding so often that the source blocks.
Draw each secret value independently from your platform's secure generator.
Quick check
Why does a narrower range matter?
Brute force cost scales with the range. Halving it halves the attacker's work.