Skip to content
XSS Write-up Intermediate

Making an XSS triggered by CSP bypass on Twitter.

A reflected XSS on Twitter's careers site was blocked by CSP, but the researcher found a JSONP-like endpoint on analytics.twitter.com that reflected a callback parameter with a JavaScript content type, allowing script execution. By combining both, the attacker could run arbitrary JavaScript in the context of careers.twitter.com.

tbmnull Follow

Published on web.archive.org

{{media:0}}

tbmnull, on web.archive.org

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 careers site reflected user input without proper encoding, and the analytics endpoint reflected a callback parameter into JavaScript without validation, allowing a script tag to load attacker-controlled code.

Impact

An attacker could execute arbitrary JavaScript in the context of careers.twitter.com, potentially stealing cookies or performing actions on behalf of the user, though the text does not detail specific consequences.

What the attacker needed

Victim clicks a crafted link

The fix

The XSS on the careers site was fixed, and the CSP bypass took longer to fix but was eventually resolved.

How it was found

  1. Find a reflected XSS in the location parameter on careers.twitter.com.
  2. Observe that CSP blocks the alert.
  3. Discover that analytics.twitter.com/tpm reflects the tpm_cb parameter with JavaScript content type.
  4. Craft a payload that injects a script tag pointing to the analytics endpoint with the alert in the callback.
  5. Load the crafted URL and see the alert execute.

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.

Cross-site scripting (XSS) lets an attacker inject JavaScript into a web page. A Content Security Policy (CSP) is a browser rule that blocks inline scripts and scripts from untrusted sources. Here, the CSP stopped the first XSS, but a second endpoint on another subdomain served attacker-controlled JavaScript, which the CSP allowed because it trusted that subdomain.

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 Twitter

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.