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.
Published on mahmoudsec.blogspot.com
June 11, 2017
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
- Attacker registers a Shopify store and a kitcrm.com account.
- Attacker sets their priority product image URL to a logging endpoint.
- Attacker tricks the victim into visiting a crafted page that CSRF-logs them into the attacker's store and kitcrm.com.
- The page redirects the victim to Facebook OAuth, which returns a code to kitcrm.com.
- 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.