Skip to content
XSS Write-up Intermediate

Stumbling across a DOM XSS on google.com

A DOM XSS existed in Google's Adsense library because user-supplied URL parameters were reflected into an iframe on google.com without proper sanitisation. An attacker could execute JavaScript in the context of google.com by crafting a malicious link.

tkiela Follow

Published on svennergr.github.io

This is a short writeup about a DOM XSS on google.com which I accidentally discovered.

tkiela (@svennergr), on svennergr.github.io

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 Adsense library failed to sanitise user-controlled parameters before inserting them into the DOM via innerHTML.

Impact

An attacker could execute arbitrary JavaScript in the context of google.com, potentially leading to data theft or other actions on behalf of the user, though the report does not demonstrate a full exploit beyond the alert.

What the attacker needed

Victim visits a malicious link; website uses vulnerable Adsense library

The fix

Google fixed the issue by returning sanitised HTML from the ads endpoint.

How it was found

  1. Open a website that uses the vulnerable Google Adsense library.
  2. Notice that URL parameters are reflected into the page.
  3. Inject an XSS payload into a URL parameter and observe the alert.
  4. Change the payload to show document.domain and confirm it is google.com.
  5. Debug the Adsense library to understand the flow and build a working PoC.

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 DOM XSS is a type of cross-site scripting where a script runs because the page's own JavaScript takes unsafe input and inserts it into the page. Here, a Google advertising library took text from the web address and put it into a Google page without cleaning it, so an attacker could make a link that runs their code on google.com.

What is XSS?

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

More from Google

View all

The newest disclosed reports for this program.

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.