Description
The product uses a Pseudo-Random Number Generator (PRNG) but does not correctly manage seeds.
PRNGs are deterministic and, while their output appears random, they cannot actually create entropy. They rely on cryptographically secure and unique seeds for entropy so proper seeding is critical to the secure operation of the PRNG. Management of seeds could be broken down into two main areas: PRNGs require a seed as input to generate a stream of numbers that are functionally indistinguishable from random numbers. While the output is, in many cases, sufficient for cryptographic uses, the output of any PRNG is directly determined by the seed provided as input. If the seed can be ascertained by a third party, the entire output of the PRNG can be made known to them. As such, the seed should be kept secret and should ideally not be able to be guessed. For example, the current time may be a poor seed. Knowing the approximate time the PRNG was seeded greatly reduces the possible key space. Seeds do not necessarily need to be unique, but reusing seeds may open up attacks if the seed is discovered.
Potential Impact
Access Control, Other
Bypass Protection Mechanism, Other
Demonstrative Examples
private static final long SEED = 1234567890;public int generateAccountID() {Random random = new Random(SEED);return random.nextInt();}Random random = new Random(System.currentTimeMillis());int accountID = random.nextInt();srand(time());int randNum = rand();# getting 2 bytes of randomness for the seeding the PRNG
seed = os.urandom(2)
random.seed(a=seed)
key = random.getrandbits(128)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 sea
Real-World CVE Examples
| CVE ID | Description |
|---|---|
| CVE-2020-7010 | Cloud application on Kubernetes generates passwords using a weak random number generator based on deployment time. |
| CVE-2019-11495 | server uses erlang:now() to seed the PRNG, which results in a small search space for potential random seeds |
| CVE-2018-12520 | Product's PRNG is not seeded for the generation of session IDs |
| CVE-2016-10180 | Router's PIN generation is based on rand(time(0)) seeding. |
Related Weaknesses
Taxonomy Mappings
- PLOVER: — PRNG Seed Error
Frequently Asked Questions
What is CWE-335?
CWE-335 (Incorrect Usage of Seeds in Pseudo-Random Number Generator (PRNG)) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product uses a Pseudo-Random Number Generator (PRNG) but does not correctly manage seeds.
How can CWE-335 be exploited?
Attackers can exploit CWE-335 (Incorrect Usage of Seeds in Pseudo-Random Number Generator (PRNG)) to bypass protection mechanism, other. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-335?
Follow secure coding practices, conduct code reviews, and use automated security testing tools (SAST/DAST) to detect this weakness early in the development lifecycle.
What is the severity of CWE-335?
CWE-335 is classified as a Base-level weakness (Medium abstraction). It has been observed in 4 real-world CVEs.