Diagnostic playbook
Predictable session identifiers (incrementing counter, timestamp, md5(counter))
Web / Session Management
Knowledge identity
Definition and taxonomy
Summary
Session identifiers are derived from predictable inputs (counters, timestamps, hashes of counters) making them guessable/enumerable instead of being cryptographically random.
Severity rationale
Demonstrated session identifiers generated from predictable sources: sequential integers (low), Unix timestamp (medium), and md5 of a sequential counter (high). A remote attacker who observes or guesses the pattern can predict another user's session id, enabling session hijacking/fixation in a real app.
Aliases
Weak session IDs, predictable session token, session prediction
Standards
CWE-384 CAPEC-59 A07:2021-Identification and Authentication Failures
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
1. First Signal
What should make an agent suspicious
Symptoms
Two consecutive requests return cookies that differ by exactly 1 (or equal the current Unix time, or are md5 of consecutive integers).
Prerequisites
Authorized lab session. An endpoint issues session identifiers; attacker can observe a series of values.
2. Recognition Logic
How to recognize this next time
If session cookies look like small integers, timestamps, or md5 of small integers, request a few in sequence and test for a predictable pattern. Compare against the current time or enumerate md5(1..N).
3. Diagnostic Procedure
Safe checks, in order
- Confirm authorized scope. 2. Issue several POSTs and capture the dvwaSession cookie each time. 3. Check for an incrementing integer pattern. 4. Compare medium values to the current Unix timestamp. 5. Decode high values as md5 of sequential integers. 6. Record the observed sequence.
4. Proof
Evidence
DVWA weak_id: low cookies 1,2,3 (increment); medium cookie equal to date +%s (1785689255); high cookies a87ff679.../e4da3b7f.../1679091c... = md5('4')/md5('5')/md5('6').
5. Controls
Negative checks
The values are reproducible from the observed pattern (next value computable), confirming predictability rather than randomness.
6. Avoid Bad Memory
False positives and traps
A cookie that differs between requests is not by itself a vulnerability; the flaw is that the next value is predictable.
7. Why It Matters
Impact
An attacker can predict and take over another user's session if the session id scheme is shared and the counter/timestamp is known.
8. Why It Happened
Root cause
Session identifiers generated from sequential counters, wall-clock time, or hashes of counters instead of a cryptographic random source.
9. Fix
Remediation and prevention
Generate session ids using a CSPRNG (e.g., PHP session id with strong entropy) with sufficient length. Rotate after login. Never use counters or timestamps.
10. Re-test
Verification steps
- After fix, issue consecutive requests and confirm ids are unpredictable and high-entropy. 2. Confirm rotation on privilege change. 3. Regression tests on randomness.
Reference
Tools and sources
Tools used
curl for cookie capture, python3 for hash/pattern verification, docker exec for read-only source review
References
OWASP Session Management Cheat Sheet; CWE-384; CAPEC-59
Intelligence
Products and history
Technologies
PHP, cookies
Affected products / versions
DVWA (Damn Vulnerable Web Application) current master
History
First documented in DVWA weak_id module in the 2026-08 benchmark run.
Exploit knowledge
Variants and references
Attack surface
dvwaSession cookie generated on each POST to the weak_id endpoint
Exploit maturity
proof-of-concept
Known variants
Sequential integer ids, time()-based ids, md5/sha1 of sequential counters, short entropy session tokens
Defensive signatures
Session cookie values that are sequential integers, current timestamps, or hex hashes of small integers; issuing multiple requests reveals an incrementing or time-derived pattern
Reproduction commands
Low (incrementing int): for i in 1 2 3; do curl -s -D - -o /dev/null -b $JAR -d 'id=1' http://127.0.0.1:4280/vulnerabilities/weak_id/ | grep -i set-cookie; done # dvwaSession=1,2,3 Medium (timestamp): curl -s -D - -o /dev/null -b $JAR -d 'id=1' http://127.0.0.1:4280/vulnerabilities/weak_id/ | grep -i set-cookie; date +%s # equal High (md5(counter)): curl -s -D - -o /dev/null -b $JAR -d 'id=1' http://127.0.0.1:4280/vulnerabilities/weak_id/ | grep -i set-cookie # a87ff679... = md5('4')
Exploit references
No external references stored; all evidence from the authorized local lab.
Case provenance