Skip to content
OAuth / SSO Write-up Advanced

Let’s steal some tokens!

The article describes three separate bug chains: stealing CSRF tokens via Google Analytics, stealing Facebook OAuth codes via a chain of CSRF and open redirect, and using a hidden-field XSS to steal WeChat OAuth codes. An attacker could use these to obtain sensitive tokens and potentially take over accounts.

Mahmoud Gamal Follow

Published on mahmoudsec.blogspot.com

June 11, 2017

Mahmoud Gamal, on mahmoudsec.blogspot.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 multiple issues: CSRF tokens leaked in URLs, missing validation of OAuth redirect URIs, and insufficient sanitisation of hidden input fields.

Impact

An attacker could steal OAuth codes and CSRF tokens, potentially leading to account takeover, though some steps required user interaction and specific configurations.

What the attacker needed

Attacker has a Shopify store; victim clicks a crafted link; victim is logged into Facebook

The fix

Shopify should set the Facebook OAuth redirect_uri to the exact callback endpoint and remove the domain from the whitelist; other issues should be fixed by validating redirect URIs and properly sanitising hidden fields.

How it was found

  1. Attacker registers a Shopify store and a kitcrm.com account.
  2. Attacker sets their priority product image URL to a logging endpoint.
  3. Attacker tricks the victim into visiting a crafted page that CSRF-logs them into the attacker's store and kitcrm.com.
  4. The page redirects the victim to Facebook OAuth, which returns a code to kitcrm.com.
  5. The product image request sends the code to the attacker's server via the Referer header.

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.

This write-up shows how small security mistakes can be combined to steal secret codes that websites use to log you in. For example, a token is like a temporary password; if an attacker can trick you into visiting a page they control, they might capture that token and use it to access your account.

What is OAuth / SSO?

Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.

More by Mahmoud Gamal

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

OAuth and single sign-on flaws

The lesson behind this report.

Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.