The Challenge
The login endpoint issues a session cookie on each request. The cookie value looks random but is generated with a weak PRNG seeded from a predictable value (timestamp, counter, or similar). Capturing two consecutive cookies reveals the pattern.
Approach
- Make two requests to the site without any credentials.
- Inspect the
Set-Cookieheader from each response. - Identify the generator — sequential integers, timestamps, or low-entropy hex. Predict or enumerate the token that would have been issued to the
adminaccount (typically the first user, token 0 or 1). - Set the forged cookie and access the protected page.
Solution
|
|
Two observations of the token stream reveal the increment step. Sending the predicted admin token (0 or 1 for the first registered user, or the value derived from the pattern) returns the admin profile page containing the flag.
What I Learned
Session tokens must be generated with a cryptographically secure random source (os.urandom, secrets.token_hex) and must be long enough (>= 128 bits) to resist enumeration. A PRNG seeded from time or a counter is predictable to anyone who can observe even one token — they can extrapolate backwards or forwards to any other valid token.