Skip to content
XSS Write-up Intermediate

Exploiting OAuth: Journey to Account Takeover

The application failed to validate the redirectUrl parameter in its OAuth flow and reflected it into a script context without sanitisation, allowing an attacker to inject JavaScript. Combined with a weak CSP that permitted inline scripts, an attacker could steal session tokens and take over a user's account.

Aditya Dixit Follow

Published on blog.dixitaditya.com

Most of the web and mobile applications these days use OAuth to secure their authorization endpoints. It allows them to easily grant access to their users to particular resources as per the application's requirements.

Aditya Dixit (@zombie007o), on blog.dixitaditya.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 redirectUrl parameter was not validated and was reflected into a script context without proper output encoding, and the CSP allowed unsafe-inline scripts.

Impact

An attacker could steal a user's session tokens and take over their account with a single interaction, though the CSP's connect-src directive limited data exfiltration to redirect-based methods.

What the attacker needed

Victim clicks a crafted link; attacker controls a server to receive tokens

The fix

The application should validate the redirectUrl parameter, implement CSRF protection with a state parameter, sanitise output to prevent XSS, and avoid unsafe-inline in CSP.

How it was found

  1. Visit the login URL with a redirectUrl parameter pointing to the dashboard.
  2. Modify redirectUrl to include a closing script tag and HTML to test for reflection.
  3. Observe that the application reflects the injected HTML.
  4. Craft a payload that uses window.location to redirect to an attacker server with the token data.
  5. Receive the session tokens on the attacker server.

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.

OAuth is a way for websites to let you log in using another service, like Microsoft. This site didn't check where it sent you after login, and it also put user input directly into a script without cleaning it. That let an attacker run their own code in your browser and steal your login tokens.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Aditya Dixit

View all

6 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.