Skip to content
Account takeover Write-up Intermediate

Unexpected gain, arbitrary forgery of user tokens.

An API endpoint that issues JWT tokens accepted an arbitrary numeric identifier in its path, so changing that number returned a valid token for a different user. An attacker could forge tokens for other accounts and use them to read those users' data.

xiaodongsec Follow

Published on medium.com

Today I’d like to share an interesting case where observing the relationship between two APIs allowed me to discover a vulnerability.

Mu1berry, on medium.com

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 token-issuing endpoint trusted the user identifier in the URL path and never checked that the caller was that user.

Impact

An attacker could obtain valid tokens for other users and use them to access those accounts' data.

What the attacker needed

A valid account; knowledge of a target user identifier

The fix

The token endpoint should only issue a token for the authenticated caller and must not accept an arbitrary user identifier from the URL.

How it was found

  1. Request the profile endpoint and note the userId in the response.
  2. Request the token endpoint with the original identifier and observe a JWT is returned.
  3. Change the identifier in the token endpoint path to another number.
  4. Receive a JWT for that other identifier.
  5. Use the new token on the profile endpoint and see a different userId returned.

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 token is a short string a site gives you after login so it knows who you are on later requests. Here the server handed out tokens for any user number you typed into the URL, without checking that you owned that account. That let someone get a token that acted as another person.

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

More by xiaodongsec

View all

11 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.