Skip to content
XSS Write-up Advanced

XSS-es in Google Caja

Google Caja's sandbox failed to account for Unicode escape sequences when filtering dangerous variable names, allowing an attacker to access the real window object and execute arbitrary JavaScript. This led to XSS on docs.google.com and later on developers.google.com via a drag-and-drop trick.

Michał Bentkowski Follow

Published on blog.bentkowski.info

The original lives on blog.bentkowski.info

We do not hold its text, 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 Caja's variable-name filtering did not decode Unicode escape sequences before checking for forbidden identifiers, so escaped names bypassed the sandbox.

Impact

An attacker could execute arbitrary JavaScript in the context of docs.google.com, and later on developers.google.com, though the second required the victim to perform drag-and-drop actions.

What the attacker needed

Victim opens a malicious document; victim performs drag-and-drop actions

The fix

Caja was fixed to decode Unicode escapes before filtering, and later a better protection was introduced.

How it was found

  1. Create a Google Docs document with an Apps Script that shows a sidebar using NATIVE sandbox mode.
  2. Put a payload in the sidebar HTML that uses a Unicode-escaped window reference to call top.eval.
  3. Open the malicious document to trigger the script and execute the payload.

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.

A sandbox is a security box that lets untrusted code run without touching the real page. Caja tried to block access to the browser's window object by scanning code for names like 'window', but it missed that JavaScript lets you write the same name using Unicode escapes. So a crafted script could still reach the real window and run code in the page.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Michał Bentkowski

View all

15 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.