Privilege Escalation like a Boss
The application used a JWT whose payload contained a userId, and the server trusted that value for authorisation. By predicting the UUID generated with Math.random() and replacing the userId in the token, the author could act as a higher-privilege admin user.
Hello guys, This is Jay Jani and after a long time, I am back with one of my finding. This one is simple Privilege Escalation on a private program of HackerOne.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the server trusted the userId inside the JWT for authorisation, and that identifier was generated with Math.random(), making it predictable.
Impact
An attacker could access the functionality reserved for an admin user, escalating privileges.
What the attacker needed
A valid low-privilege account; ability to read the site's JavaScript
How it was found
- Capture requests and notice an authorization header carrying a JWT on each one.
- Decode the JWT and see it contains userId, IP, browser and OS information.
- Find the JavaScript file that generates the UUID and confirm it uses Math.random().
- Break the random function to recover a user id in plaintext.
- Re-encode the JWT with the replaced user id and send it to reach admin functionality.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A JSON Web Token is a signed piece of data a site gives you after login, and the site reads it on each request to know who you are. Here the token held a user identifier, and the server believed whatever identifier was inside it. Because the identifier was made with a weak random function, the author could work out another user's identifier and put it in the token to be treated as that user.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.