Skip to content
OAuth / SSO Write-up Intermediate

1-CLick OAuth Token Hijacking via Google Apps Script – A Design

A malicious editor of a Google Apps Script project can deploy a web app that exfiltrates the OAuth token of any user who visits its link, without modifying the original script. The stolen token allows the attacker to access the victim's Google Drive, Gmail, and other services according to the granted scopes.

Ph.Hitachi Follow

Published on infosecwriteups.com

While reviewing how Google Apps Script handles authorization, I stumbled upon a significant yet subtle security gap — OAuth tokens can be exfiltrated and abused silently within the same script project.

Ph.Hitachi, 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, Google Apps Script allows any editor of a project to deploy a web app that runs as the visiting user and can read that user's OAuth token, with no owner notification or ownership control over deployments.

Impact

The attacker could access and modify the victim's Google Drive files, send emails as the victim, and perform other actions allowed by the granted scopes; Google declined to fix the issue, and its suggested mitigations (audit logs, limiting fetch domains) are either not real-time or bypassable.

What the attacker needed

Attacker has editor access to the script project; victim visits the attacker's web app link; victim has a Google account

The fix

Should be fixed by giving project owners control and notification over web app deployments and by preventing deployed scripts from reading the visiting user's OAuth token without explicit consent.

How it was found

  1. A malicious editor adds a new script file to the project and deploys it as a web app set to execute as the user accessing it.
  2. The attacker deletes the new script file, but the deployed web app remains active and linked to the project.
  3. The attacker sends the web app link to a victim (owner, editor, or customer).
  4. When the victim visits the link, the web app reads the victim's OAuth token and sends it to the attacker's server.

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.

Google Apps Script lets people write small programs that run inside Google's servers and can access a user's Google data after the user grants permission. The permission is represented by a secret string called an OAuth token. The report shows that someone with edit access to a script project can quietly add a second program that steals this token from anyone who opens its link, giving the attacker the same access 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 Ph.Hitachi

View all

9 more disclosed reports, 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.