Token Expired Error and IDOR: Unauthorized Access in an ASP.NET Application
A login endpoint accepted requests where the email and password parameters were removed, returning a session and JWT token for whatever CustomerId and UserId were supplied. An attacker could obtain valid sessions and tokens for other users and read their email, national ID number and name.
— After a long time I was motivated to share a critical finding that excited me and to describe the process I followed during the time I discovered it. I hope sharing this vulnerability story will be useful to you as well.
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 login handler trusted client-supplied CustomerId and UserId to pick the account and issued a session and token without verifying the supplied credentials.
Impact
An attacker could obtain a valid session and JWT token for other users and access their personal data such as email, national ID number and name.
What the attacker needed
Knowledge of a valid CustomerId and UserId
How it was found
- Find the login endpoint and note the email, password, CustomerId and UserId parameters.
- Remove the CustomerId and UserId values and send the request, observing a token expired error.
- Remove the email and password parameters while keeping CustomerId and UserId fixed.
- Send the request and receive a session and JWT token for those identifiers.
- Decode the token to read the user's email, national ID number and name.
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 login page should only give you a session when you prove who you are with a correct password. Here the server ignored the password entirely and trusted two numbers in the request that identify the account, so anyone who guessed or knew those numbers got logged in as that person. This is called an insecure direct object reference: the app uses an identifier from the user without checking the user is allowed to use it.
What is IDOR?
One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.