Skip to content
IDOR Write-up Intermediate

Insecure Refresh Token Usage Leads to Account Takeover (IDOR)

The OAuth2 token endpoint did not verify that a supplied refresh token belonged to the authenticated session, so an attacker could exchange another user's refresh token for that user's JWT access token. This allowed full impersonation and account takeover, though the refresh token was a non-guessable UUID and the report was rated P5.

medium.com

Published on medium.com

In this write-up, I detail an IDOR vulnerability found not in the main application domain, but in the authentication domain. This flaw allowed me to obtain the JWT access token of any user by abusing the OAuth2 refresh token flow.

Mahmoud Gamal, 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 endpoint failed to bind the refresh token to the authenticated user or session, and refresh tokens were long-lived and static.

Impact

An attacker who obtained another user's refresh token could fully impersonate that user, but the token was a non-guessable UUID and the report was rated P5.

What the attacker needed

Attacker has a valid session; attacker obtains victim's refresh token

How it was found

  1. Observe the browser sending a POST request to the authentication domain's token endpoint with grant_type, refresh_token and client_id.
  2. Create a second account and obtain its refresh token.
  3. Send the second account's refresh token in the token request from the first account's session.
  4. Receive the second account's JWT access token in the response.

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 a long-lived secret that a website uses to get a new access token without asking you to log in again. Here, the server accepted any valid refresh token from any logged-in session, so if an attacker somehow obtained someone else's refresh token, they could get that person's access token and act as them. The report notes the token was a random UUID, so it could not be guessed.

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.

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

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.