Run static analysis (SAST) on the codebase looking for the unsafe pattern in the data flow.
Predictable from Observable State
This vulnerability occurs when an attacker can guess or deduce sensitive values, like random numbers or identifiers, by observing predictable system or network characteristics such as timestamps,…
What is CWE-341?
Real-world CVEs caused by CWE-341
-
Mail server stores private mail messages with predictable filenames in a world-executable directory, which allows local users to read private mailing list archives.
-
PRNG allows attackers to use the output of small PRNG requests to determine the internal state information, which could be used by attackers to predict future pseudo-random numbers.
-
DNS resolver library uses predictable IDs, which allows a local attacker to spoof DNS query results.
-
MFV. predictable filename and insecure permissions allows file modification to execute SQL queries.
Step-by-step attacker path
- 1
This code generates a unique random identifier for a user's session.
- 2
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.
- 3
This example also exhibits a Small Seed Space (CWE-339).
Vulnerable PHP
This code generates a unique random identifier for a user's session.
function generateSessionID($userID){
srand($userID);
return rand();
} Secure pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
const safe = validateAndEscape(input);
return executeWithGuards(safe);
} How to prevent CWE-341
- Implementation Increase the entropy used to seed a PRNG.
- Architecture and Design / Requirements Use products or modules that conform to FIPS 140-2 [REF-267] to avoid obvious entropy problems. Consult FIPS 140-2 Annex C ("Approved Random Number Generators").
- Implementation Use a PRNG that periodically re-seeds itself using input from high-quality sources, such as hardware devices with high entropy. However, do not re-seed too frequently, or else the entropy source might block.
How to detect CWE-341
Run dynamic application security testing against the live endpoint.
Watch runtime logs for unusual exception traces, malformed input, or authorization bypass attempts.
Code review: flag any new code that handles input from this surface without using the validated framework helpers.
Plexicus auto-detects CWE-341 and opens a fix PR in under 60 seconds.
Codex Remedium scans every commit, identifies this exact weakness, and ships a reviewer-ready pull request with the patch. No tickets. No hand-offs.
Frequently asked questions
What is CWE-341?
This vulnerability occurs when an attacker can guess or deduce sensitive values, like random numbers or identifiers, by observing predictable system or network characteristics such as timestamps, process IDs, or other public information.
How serious is CWE-341?
MITRE has not published a likelihood-of-exploit rating for this weakness. Treat it as medium-impact until your threat model proves otherwise.
What languages or platforms are affected by CWE-341?
MITRE has not specified affected platforms for this CWE — it can apply across most application stacks.
How can I prevent CWE-341?
Increase the entropy used to seed a PRNG. Use products or modules that conform to FIPS 140-2 [REF-267] to avoid obvious entropy problems. Consult FIPS 140-2 Annex C ("Approved Random Number Generators").
How does Plexicus detect and fix CWE-341?
Plexicus's SAST engine matches the data-flow signature for CWE-341 on every commit. When a match is found, our Codex Remedium agent opens a fix PR with the corrected code, tests, and a one-line summary for the reviewer.
Where can I learn more about CWE-341?
MITRE publishes the canonical definition at https://cwe.mitre.org/data/definitions/341.html. You can also reference OWASP and NIST documentation for adjacent guidance.
Weaknesses related to CWE-341
Generation of Predictable Numbers or Identifiers
This vulnerability occurs when a system creates numbers or identifiers that are too easy to guess, undermining security mechanisms that…
Predictable Exact Value from Previous Values
This vulnerability occurs when a system uses a predictable sequence for generating values, allowing an attacker to accurately guess future…
Predictable Value Range from Previous Values
This vulnerability occurs when a system's random number generator produces values that, after observing previous outputs, allow an…
Don't Let Security
Weigh You Down.
Stop choosing between AI velocity and security debt. Plexicus is the only platform that runs Vibe Coding Security and ASPM in parallel — one workflow, every codebase.