Generate each value independently rather than calculating it from earlier outputs or state an attacker can observe. If the value is security-sensitive, use a cryptographically secure source of randomness and avoid simple increments, deltas, or reused seeds. Review algorithms, initialisation, and state handling so previous values do not reveal the next one.
Why previous values should never be enough to guess the next one
The core rule is independence: each security-sensitive value should be generated from fresh entropy, not derived from a prior output, counter, timestamp pattern, or any state an attacker can observe. If the next value can be inferred from the last one, the design has turned randomness into a predictable sequence. That weakness shows up in tokens, session identifiers, password reset codes, nonces, and similar security material.
Predictability is especially dangerous when the value has to defend against guessing, replay, or correlation. A sequence that looks random to the developer may still expose a stable pattern to an observer who can collect multiple samples, compare deltas, or recover initialization details. Once the pattern is visible, the attacker does not need to break the algorithm, only its assumptions.
What usually creates predictable values
The most common failure is reusing state as if it were randomness. Simple increments, arithmetic offsets, reused seeds, and deterministic transformations all preserve enough structure for an attacker to model the sequence. Even when the values appear different, a weak generator can leak the relationship between one output and the next through its internal state.
Implementation details matter as much as the algorithm name. A strong generator can still be undermined by poor initialization, shared state across requests, unsafe cloning, or resetting the seed in a repeatable way during startup. Developers should also be wary of hidden predictability in framework helpers, test fixtures, and default configuration that silently replace cryptographic randomness with convenience.
The safest approach is to treat any value that protects access, integrity, or confidentiality as a security control rather than a formatting detail. For a compact practitioner reference on common weakness patterns, see the CWE Top 25 Guide, which helps map predictable-value failures to the underlying weakness class.
How to verify the design is actually unpredictable
Review the full generation path, not just the final line of code. Check where entropy enters the system, whether the same seed can be reused, whether state survives longer than intended, and whether the value is ever derived from prior outputs for convenience or performance. If the answer depends on a counter or sequence number, confirm that the counter is not itself exposed or usable as a predictor.
Testing should include negative checks, not just happy-path validation. Generate many values in a row, restart the process, compare outputs across instances, and confirm that no visible structure survives across sessions, nodes, or deployments. If multiple environments or replicas can produce the same sequence, the risk is not theoretical, because an attacker only needs one valid prediction path.
For application teams that need implementation guidance on randomness, tokens, and secure handling patterns, the OWASP Cheat Sheet Series is a useful companion for turning the design rule into code review checkpoints.
Risk and Threat Considerations
Predictable values often become a direct attack primitive. If an attacker can infer the next token, nonce, reset code, or identifier, they may bypass authentication, hijack a session, replay a request, or enumerate sensitive objects. The danger is amplified when the value is accepted by multiple services or lives long enough for an attacker to observe a few samples first.
Failure mechanism: The generator leaks structure through deterministic state, weak seeding, or reused initialization, allowing an observer to infer future outputs from past ones.
Impact: Predictable security values can lead to account takeover, unauthorized access, request forgery, and exposure of sensitive application state, especially when the value is trusted by downstream systems.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP ASVS, CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V9 — Self-contained Tokens | Predictable values threaten token and nonce strength in application security. |
| V6 — Authentication | Predictable values can undermine authentication flows and recovery mechanisms. | |
| V7 — Session Management | Session identifiers must not be predictable from earlier values or counters. | |
| Recommendation — Use V9 checks to ensure tokens and nonces are independently generated and non-predictable. Validate that authentication-related values cannot be guessed from prior outputs or state. Generate session values with cryptographically secure randomness and no observable sequence. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | Secure application design must prevent predictable security values in code and components. |
| Recommendation — Review application logic for deterministic token and identifier generation. | ||
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | Security-sensitive values like reset codes and authenticators need secure lifecycle handling. |
| Recommendation — Ensure authenticators and related secrets are generated with approved randomness and protected from reuse. | ||
Practitioner Guidance
What to verify: Confirm that the value is generated from a cryptographically secure source of randomness and that no code path falls back to counters, timestamps, or repeatable seeds in production. Also verify that startup, restart, and multi-instance behaviour cannot recreate the same sequence.
Common mistake: Teams often fix the obvious generator call but leave the surrounding state logic untouched. If the value is still derived from a previous output, or if the seed can repeat after deployment, the sequence remains predictable even when the API looks secure.
Practitioner takeaway: Security-sensitive values must be independently generated and operationally isolated from prior outputs, because predictability usually enters through state handling, not through the final value format.
Related resources from NHI Mgmt Group
- How do developers prevent incomplete identification of uploaded file variables in PHP?
- How do developers prevent External Control of System or Configuration Setting?
- How can developers prevent path traversal using a Windows UNC share path?
- How do developers prevent Compiler Removal of Code to Clear Buffers?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 18, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org