Skip to content

Field manual · ATO · Part IV

OAuth & Social Login

The Trojan-horse flows

2 min readBroken Access Control

Part IV: OAuth and social login: the Trojan-horse flows

Section titled “Part IV: OAuth and social login: the Trojan-horse flows”

Why care: OAuth lets a third party vouch for identity. Most of these bugs exploit the handoff between that vouch and the session it creates. OAuth ATO deserves its own guide; these are the core instincts:

Victim Browser User-Agent Identity Provider Google / GitHub / IdP Target App Callback & Session 1. /authorize?redirect_uri=...&state=... ATTACK 1 · redirect_uri bypass Path traversal or open redirect steals code 2. 302 redirect_uri?code=ABC&state=XYZ 3. GET /callback?code=ABC (ATTACK 2: missing state = Login CSRF / Account Link ATO) 4. Exchange code -> email match ATTACK 3 · Unverified email auto-merge App links IdP email to existing account without password
Figure 1 Three high-impact interception points in OAuth 2.0 login: leaking the authorization code via redirect_uri, forging the callback without state, and abusing email auto-linking.
- login-CSRF: victim's browser completes YOUR OAuth flow with attacker's session → victim logged into your account (login CSRF),
beautiful for capture: you watch what they do. Reported often as "login CSRF."
- code interception: authorization code `state` binding missing + code arrives at callback with predictable/leaky param.
- Redirect URI whitelist bypasses: /callback/../attacker, /callback%2f..%2f, /callback?next=evil, open-redirect
INSIDE the redirect → code leaks to your page.

4.2 Email-as-identity (the classic ATO lever)

Section titled “4.2 Email-as-identity (the classic ATO lever)”
Provider gives app: {"email":"victim@x.com","verified":true}
App says: "email matches existing account → link/takeover"

Break of the burden of proof is on the IdP being honest. Attack angles:

  • Register at the IdP with victim’s email if IdP doesn’t verify
  • Use a different IdP whose emails the app trusts but which is spoofable
  • Unicode/case/space tricks in matching (victim @x.com, VICTIM@x.com, victim+evil@x.com), the +tag trick sometimes bypasses uniqueness matching but matches victim on the app side
Already have app account; "Connect with Google" links Google identity to your app account.
Now: link with an OAuth identity under YOUR control, but submit it in a flow bound to VICTIM's session
(or vice versa — link YOUR identity into victim's account via UI race / parameter control)
→ attacker's OAuth identity on victim's account = attacker logs in as victim via OAuth. FULL ATO.
Start OAuth login as YOU → get your `code`
Complete the OAuth flow but swap `code` to VICTIM's code in YOUR browser
(mitigation: state parameter — if state missing/unvalidated, or the code is bound to session not state)
→ your session finalized with victim's identity

4.5 Device authorization grant: phishing with a real code

Section titled “4.5 Device authorization grant: phishing with a real code”

The device grant exists for TVs, CLIs, and IoT boxes that cannot show a browser. The device shows a short user code; the user types it into a real page and approves. The flow is legitimate, which is exactly what makes it a phishing primitive.

The attack is social, but the token is real. You start a device grant against the target and receive a genuine user code from the target’s own authorization server. You send the victim the real verification URL and the real code. They approve on the real site. Your device polls, receives the token, and now holds their session. Nothing in the page looks fake because nothing is fake.

POST /oauth/device/code (attacker device starts the flow)
-> { "user_code": "WDJB-MJHT", "verification_uri": "https://login.target.com/activate" }
Attacker sends victim: "Approve this device: login.target.com/activate code WDJB-MJHT"
Victim approves on the genuine site.
Attacker poll returns access + refresh tokens.

What to check on a program that exposes the device grant:

  • Does approval show the device, location, and app clearly, or just a bland approve button?
  • Does the user code expire fast, and is it rate-limited against brute force?
  • Does approval require re-authentication, or does an already signed-in victim approve in one tap?

Demonstrate it between two accounts you own: one plays the device, one plays the victim. Report it as a phishing-assisted ATO with the token as proof, and stop there.

Next step: Part V covers the session layer itself, what holds the door open once any of these flows hands out a token.

Connections5 backlinks · 0 outgoing · 2 cross-guideFull graph →
Open local graph around this page
Open full graph →
Click a node to open · Drag to reposition · Scroll to zoom

Broken Access ControlFor authorized security research only: bug bounty programs, your own systems, or scoped engagements with written permission.