CWE-336: Same Seed in Pseudo-Random Number Generator (PRNG)

Export to Word

Description

A Pseudo-Random Number Generator (PRNG) uses the same seed each time the product is initialized.

Extended Description

Given the deterministic nature of PRNGs, using the same seed for each initialization will lead to the same output in the same order. If an attacker can guess (or knows) the seed, then the attacker may be able to determine the random numbers that will be produced from the PRNG.


ThreatScore

Threat Mapped score: 0.0

Industry: Finiancial

Threat priority: Unclassified


Observed Examples (CVEs)

Related Attack Patterns (CAPEC)

N/A


Attack TTPs

N/A

Modes of Introduction

Phase Note
Implementation REALIZATION: This weakness is caused during implementation of an architectural security tactic.

Common Consequences

Potential Mitigations

Applicable Platforms


Demonstrative Examples

Intro: The following code uses a statistical PRNG to generate account IDs.

Body: Because the program uses the same seed value for every invocation of the PRNG, its values are predictable, making the system vulnerable to attack.

private static final long SEED = 1234567890; public int generateAccountID() { Random random = new Random(SEED); return random.nextInt(); }

Intro: This code attempts to generate a unique random identifier for a user's session.

Body: Because the seed for the PRNG is always the user's ID, the session ID will always be the same. An attacker could thus predict any user's session ID and potentially hijack the session.

function generateSessionID($userID){ srand($userID); return rand(); }

Notes

← Back to CWE list