833
Applicable Platforms
Language : Not Language-Specific (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Other
Access Control
Other
Bypass Protection Mechanism
Detection Methods
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST),
can find some instances of this weakness by analyzing source code (or binary/compiled code)
without having to execute it. Typically, this is done by building a model of data flow and control
flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input)
with "sinks" (destinations where the data interacts with external components, a lower layer such
as the OS, etc.)
Effectiveness = High
Potential Mitigations
Phase: Architecture and Design
Do not reuse PRNG seeds. Consider a PRNG that periodically re-seeds itself as needed from a
high quality pseudo-random output, such as hardware devices.
Phase: Architecture and Design
Phase: Requirements
Strategy = Libraries or Frameworks
Use products or modules that conform to FIPS 140-2 [REF-267] to avoid obvious entropy
problems, or use the more recent FIPS 140-3 [REF-1192] if possible.
Demonstrative Examples
Example 1:
The following code uses a statistical PRNG to generate account IDs.
Example Language: Java (Bad)
private static final long SEED = 1234567890;
public int generateAccountID() {
Random random = new Random(SEED);
return random.nextInt();
}
Because the program uses the same seed value for every invocation of the PRNG, its values are
predictable, making the system vulnerable to attack.
Example 2:
This code attempts to generate a unique random identifier for a user's session.
Example Language: PHP (Bad)
function generateSessionID($userID){
srand($userID);
return rand();
}
CWE Version 4.14
CWE-337: Predictable Seed in Pseudo-Random Number Generator (PRNG)
CWE-337: Predictable Seed in Pseudo-Random Number Generator (PRNG)