Skip to content
OAuth / SSO Write-up Advanced

Google Cloud Account Takeover via URL Parsing Confusion

A URL parsing discrepancy in Google's OAuth redirect_uri validation allowed an attacker to craft a redirect URI that Google's backend treated as a loopback address while the browser treated it as an attacker-controlled domain. This let the attacker impersonate the gcloud CLI and steal the victim's OAuth grant, leading to full account takeover with stealthy backdoor access.

Mohamed Benchikh Follow

Published on infosecwriteups.com

This article walks through a unique OAuth account takeover vulnerability I had recently discovered affecting several Google services. It arises from URL parsing confusion when handling redirecturi OAuth parameter.

Mohamed Benchikh, on infosecwriteups.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 the OAuth server's URL parser used the first '@' as the delimiter between userinfo and host and ignored trailing parts, while browsers use the last '@', so a URL with two '@' signs was validated as a loopback address but resolved to an attacker domain.

Impact

The attacker could obtain an access token granting unrestricted access to the victim's Google Cloud account, potentially with long-term stealthy backdoor access and no visibility to the user.

What the attacker needed

Victim clicks a link; victim logs in and consents; attacker controls a domain

The fix

Google patched the vulnerability after responsible disclosure.

How it was found

  1. Craft a malicious OAuth authorization request with a redirect_uri containing two '@' signs and IPv6 loopback addresses.
  2. Send the link to the victim.
  3. The victim sees a legitimate Google Cloud SDK consent screen and logs in.
  4. After consent, the victim is redirected to the attacker's host with the OAuth grant.
  5. The attacker uses the grant to make API calls on 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.

OAuth is a way for apps to let you log in with another service (like Google) without sharing your password. The service sends a temporary code back to the app using a 'redirect address' (redirect_uri). If that address can be tricked, an attacker can receive the code instead and use it to access your account. Here, a malformed web address was read differently by Google's server and by the browser, so the code went to the attacker.

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 Mohamed Benchikh

View all

2 more disclosed reports, best first.

More from Google

View all

The newest disclosed reports for this program.

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.