Skip to content
XSS Disclosed report Intermediate

XSS and cache poisoning via upload.twitter.com on ton.twitter.com

The upload service accepted files with unknown extensions and served them without a Content-Type header, so browsers sniffed the content as HTML and executed script. An attacker could also upload an HTML5 AppCache manifest to poison the victim's browser cache on the same domain, making the XSS persistent and altering other pages.

File Descriptor Follow

Originally disclosed on HackerOne

  • Triaged in 7 hours
  • Fixed in 22 months
  • Paid in 3 days
  • Disclosed after 3.7 years

Hi, I would like to report an issue where attackers can bypass the upload restriction on upload.twitter.com to cause XSS on ton.twitter.com and cache poisoning.

##Detail When using upload.twitter.com to upload audience data, it checks if the file type is allowed and rejects any harmful files (e.g. .html). However it fails to reject files with unknown file type. For example, foobar.html is rejected while foobar.test is passed. Since the server does not recognize the file type, it outputs the file without sending the Content-Type header in the response. The lack of such header results in browser sniffing for the document type. In this case, attackers can insert HTML to perform XSS. Normally the file uploaded is only accessible to the uploader which makes it a self-XSS, but with signed requests attackers can force victims to be able to view the file, thus triggering XSS on behalf of the victim.

###Cache poisoning Attackers can take this attack further and perform cache poisoning on victim's browser. Since it allows uploading files, attackers can upload a cache manifest file (HTML5 AppCache) to control the cache behaviors over ton.twitter.com. There are two things the attacker can achieve:

  1. Attacker can force victim's browser to cache the XSS file. That means it creates a persistent XSS on victim's browser even if the XSS file on the server is removed.
  2. Attacker can control all returning contents on the domain. For example, attacker can replace contents of any file on ton.twitter.com (in victim's perspective)

##Repo step

  1. Go to Twitter Ads > Tools > Audience manager > Create new list audience
  2. Upload a normal file under "Upload your data file." and intercept the request
  3. Change the parameter blobstore_url with an unknown suffix (e.g. 1440354519600.txt => 1440354519600.test)
  4. Replace the parameter content with any XSS vector (e.g. <script>alert(1)</script>)
  5. The uploaded file now contains XSS
  6. To make it accessible to others, sign it with OAuth token

##PoC You may also visit http://innerht.ml/pocs/twitter-upload-xss to see the attack in action.

Video demo: https://vimeo.com/137155736 (password: appcache)

The PoC demonstrates the XSS. It also shows how it can influence contents of other pages (poisoning http://ton.twitter.com/).

The original report as published on HackerOne, by filedescriptor. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the upload validation only blocked known dangerous extensions instead of allowing only safe types, and the response omitted a Content-Type header, enabling MIME sniffing.

Impact

An attacker could run script in a victim's browser on the ton.twitter.com domain and, via an AppCache manifest, make the XSS persistent and control other content on that domain from the victim's perspective.

What the attacker needed

Twitter Ads account; victim views the uploaded file; OAuth token to sign the request

How it was found

  1. Open the Twitter Ads audience manager and start creating a new list audience.
  2. Upload a normal data file and intercept the request.
  3. Change the blobstore_url parameter to use an unknown file suffix.
  4. Replace the content parameter with an XSS vector.
  5. The uploaded file now contains the XSS payload.
  6. Sign the request with an OAuth token to make the file accessible to others.

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 report has not been written yet. The Original tab links to the source.

A website that lets people upload files should check what kind of file it is and tell the browser how to treat it. Here, files with unusual endings were allowed and sent back without that instruction, so the browser guessed it was a web page and ran any script inside. The attacker also used a browser caching feature to make the malicious page stick around and affect other pages on the same site.

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 File Descriptor

View all

20 more disclosed reports, best first.

More from X / xAI

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.