Skip to content
XSS Write-up Intermediate

Widespread XSS Vulnerabilities in Ad Network Code

Ad network code on many popular sites failed to escape the URL fragment (hash) value before writing it into the page, allowing an attacker to inject JavaScript via a crafted link. This could let an attacker run arbitrary script in the context of the victim site, potentially leading to session hijacking and account takeover.

randywestergren.com

Published on randywestergren.com

For most of us, the title of this post may not be very surprising. Any time we allow 3rd party scripts to run on our sites, we effectively relinquish control of the code that executes on the client.

Randy, on randywestergren.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 ad network code inserted the page URL (including the hash) into a JavaScript context without proper escaping or encoding.

Impact

An attacker could leverage these vulnerable ads to hijack sessions, leading to a complete account takeover; the text notes that mitigation is difficult and that some vendors patched their components.

What the attacker needed

Victim clicks a crafted link; vulnerable ad or third-party script present

The fix

The affected ad network and third-party components were patched after being reported, but the text suggests publishers should pressure ad providers to fix such issues or switch providers.

How it was found

  1. Visit a popular site with a crafted XSS payload in the URL hash.
  2. Observe that the hash is picked up by the advertising provider client-side and sent through ad requests.
  3. See the payload break out of the document.write and execute JavaScript.

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 visit a website, the part of the address after the # symbol (the hash) is normally not sent to the server, but some third-party ad scripts read it and insert it into the page without cleaning it. If an attacker tricks you into clicking a link with malicious code in the hash, that code can run as if it came from the website you are visiting. This is called cross-site scripting (XSS), and it can let an attacker steal your session or act as you on that site.

What is XSS?

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

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.