Skip to content
Account takeover Write-up Intermediate

Token of Misfortune: How a Refresh Token Leak Let Me Regenerate Unlimited Sessions

A refresh token was hardcoded in client-side JavaScript, and the refresh endpoint lacked expiration, revocation, or binding checks. An attacker could use it to generate unlimited access tokens and access other users' data, including admin endpoints.

infosecwriteups.com

Published on infosecwriteups.com

Free Link🎈

Iski, on infosecwriteups.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 refresh token was stored client-side and the server did not implement expiration, revocation, or binding to user/device, allowing unlimited token generation.

Impact

The attacker could generate unlimited access tokens, leading to account takeover, persistent session regeneration, and exposure of data for over 100,000 users.

What the attacker needed

Access to the client-side JavaScript; knowledge of the refresh endpoint

The fix

The refresh token should not be stored client-side, and the server should implement token expiration, revocation, reuse detection, and binding to device or IP.

How it was found

  1. Crawl a subdomain and find a JavaScript bundle file.
  2. Search the JavaScript file for token-related strings and discover a hardcoded refresh token.
  3. Find the refresh endpoint from another JavaScript file.
  4. Send a POST request with the refresh token to the refresh endpoint.
  5. Receive a new access token in the response.
  6. Use the access token to access authenticated endpoints, including admin ones.

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 refresh token is like a long-term key that lets you get new short-term keys (access tokens) without logging in again. Here, that key was left in the website's code, and the server never checked if it was still valid or who was using it, so anyone could use it to get new keys and access private data.

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.

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.