Skip to content
OAuth / SSO Write-up Advanced

The Header That Signed Itself: Full Account Takeover in a Google

The server derived an OAuth state value from the client-controlled X-Forwarded-Host header and signed it, then later trusted that signed state to redirect the Google authorization code to the attacker's domain. An unauthenticated attacker could steal a victim's Google OAuth authorization code and exchange it for a session, achieving full account takeover.

Abdelrhman Amin Follow

Published on uchihamrx.medium.com

.بِسْ� اللَّه الرَّحْ� ن الرَّحِي� . . اللَّه� َّ صَلِّ وَسلَّ� وبارك على نَبِينَا � ُح� َّد

Abdelrhman Amin, on uchihamrx.medium.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

The server trusted a client-controlled header (X-Forwarded-Host) to build a signed OAuth state and then used that signed state as a redirect target without validating the origin or binding the code to the session.

Impact

An unauthenticated attacker could steal a victim's Google OAuth authorization code and exchange it for a full session, leading to complete account takeover without phishing or compromising Google.

What the attacker needed

Victim clicks a link or visits a page; attacker controls a domain; victim completes Google login

The fix

The server should not derive the OAuth state from client-controlled headers; it should use a server-side mapping of organization to origin, validate the origin at callback, and enforce PKCE and session binding during code exchange.

How it was found

  1. Send a request to /googlelogin with a legitimate Host header and an X-Forwarded-Host header pointing to the attacker's domain.
  2. Observe that the server returns a state parameter containing the attacker's domain and a valid HMAC signature.
  3. Initiate the OAuth flow with a victim account; Google redirects to /oauthcallback with a code and the signed state.
  4. The server responds with a redirect to the attacker's domain, forwarding the authorization code.
  5. Use the stolen code and the attacker's own oauth2XsrfState cookie to call /oauthcblogin and obtain a JWT.
  6. Exchange the JWT for session cookies via /api/auth/saveAuth and access the victim's account.

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.

When you log in with Google, the website sends you to Google and Google sends you back with a special code. This website put a web address inside a signed value called 'state' and later used that address to decide where to send the code. An attacker could make the website sign a state containing the attacker's address, so the victim's code was sent to the attacker, who then logged in as the victim.

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 Abdelrhman Amin

View all

1 more disclosed report, 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.