Skip to content
Account takeover Write-up Intermediate

Random account takeover via misconfigured OAuth

The staging and production environments used the same JWT signing secret and structure, so a token issued by the staging app was accepted by the main app. An attacker could register on staging and use that token to log in to the main app as whichever user had the same sequential ID, effectively taking over random accounts.

Berserker1337 Follow

Published on medium.com

Hey, I hope y’all are doing great. This vulnerability is an account takeover for random users and I believe that this might be common.

Berserker, 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 staging and production environments shared the same JWT signing secret and token structure, so tokens were not isolated per environment.

Impact

An attacker could take over random accounts on the main site (and possibly the mobile app) whose sequential ID matched their staging account, though they could not choose which user to target.

What the attacker needed

Access to the staging environment; ability to register an account on staging; victim has the same sequential ID as attacker

The fix

The developers should use different secrets for signing JWTs in different environments so a token from one environment cannot be used in another.

How it was found

  1. Go to the staging environment.
  2. Register a new account and note the sequential user ID assigned.
  3. After logging in, copy the Authorization token from the browser or API response.
  4. Go to the main site and replace the Authorization token with the staging token.
  5. Access an authenticated feature and observe you are logged in as the user with the same ID from staging.

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 (JWT) is a signed piece of data a website gives you after login to prove who you are. If two different websites use the same secret key to sign those tokens, a token from one site will be trusted by the other. Here the staging site and the main site shared that key, so a token from staging worked on the main site and logged the attacker in as a different user who happened to have the same numeric ID.

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 Berserker1337

View all

2 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.