# Confused Deputy: Google IdP Universal Account Takeover via Device Code Flow Hijacking // weirdmachine64

Google's device-code flow let a sign-in session be transferred via URL and client_id/scope swapped, so one link silently yielded tokens for any Google client.

- Payout: $13,337
- Severity: critical
- Program: Google
- Found by: Mohamed Benchikh
- Disclosed: 2026-07-15
- Write-up quality: 9/10
- Original: https://weirdmachine64.github.io/research/google-oauth-device-code-hijacking.html
- Library page: https://bugbountylibrary.com/r/blog%3Aweirdmachine64-github-io-research-google-oauth-device-code-hijacking-html
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:blog sev:critical tech:oauth technique:chained technique:param-pollution vuln:account-takeover vuln:auth-bypass vuln:mfa-bypass

**Target:** OAuth 2.0 device authorization grant (accounts.google.com/v3/signin/challenge, oauth2.googleapis.com/device/code, /token)
**Root cause:** The device-code sign-in session is anchored only by a transferable TL blob in the URL, and the authorization server never binds client_id/scope to the device_code server-side, trusting query-string values at consent time.
**Steps:**
1. POST `https://oauth2.googleapis.com/device/code` to get device_code + user_code
2. Open `google.com/device`, enter user_code, enter an email to reach `accounts.google.com/v3/signin/challenge/...?TL=<blob>`
3. Copy that challenge URL into a second browser; complete normal Google sign-in there; the original device's poll returns a token
4. Edit the URL: swap `client_id` to another Google client (e.g. Cloud SDK) and `scope` to `cloud-platform compute appengine.admin`; consent screen reflects new client/scopes; poll still returns token for substituted scopes
5. Add `prompt=none` with `scope=openid email profile` and a third-party client_id (e.g. Facebook); victim opening link silently yields id_token
6. Replay id_token against the app's Sign in with Google endpoint; for Gmail use token with `https://mail.google.com/` scope via IMAP XOAUTH2 on imap.gmail.com:993
**How found:** Setting up YouTube TV on a PS5 prompted curiosity about the device flow; tried copying the consent URL to a second browser (failed), then noticed entering an email produced a challenge URL with a TL blob that did transfer; then noticed client_id/scope were unbound query params with no redirect_uri, and tested substitution.
**Exploitation:** Attacker builds a device-code URL, substitutes an arbitrary Google-registered client_id and elevated scopes, adds prompt=none, and sends it to a victim who has previously granted openid/email/profile to that client. Victim opening the link completes a normal Google sign-in (satisfying 2FA), and the attacker's polling script receives an id_token/access token for the substituted client, enabling account takeover, persistent refresh via accounts.reauth, and full Gmail access via IMAP XOAUTH2.
**Escalation:** Chained transferable session + unbound client_id/scope + prompt=none; escalated from YouTube TV scopes to Cloud SDK scopes, then to arbitrary third-party clients and Gmail IMAP access; accounts.reauth for persistent backdoor.
**Insight:** In device-code flows, test whether the intermediate challenge/session URL is portable across browsers and whether client_id/scope in that URL are re-validated against the device_code at consent; also check alternate protocol doors (IMAP XOAUTH2) when the REST API is project-gated.

## Proof of concept (copied exactly from the original report)

**Device-code URL with swapped client_id and scope**

```
accounts.google.com/v3/signin/challenge/…
 ?TL=APouJz6T… <- encrypted session state
 &response_type=none
 &client_id=861556708454-… <- YouTube TV
 &scope=… <- YouTube scopes
```

**prompt=none one-click link against Facebook client_id**

```
Take the weaponized device-code URL, drop in Facebook's client_id (any site using "Sign in with Google" works the same way), set scope=openid email profile, add prompt=none. The victim opens the link, and that's the only action required: no consent screen, no button to press. The browser silently completes the flow in the background, the polling script receives an id_token for that third-party application, and that token replays cleanly against the app's own "Sign in with Google" endpoint.
```

