Skip to content
XSS Write-up Advanced

An XSS on Facebook via PNGs and Wonky Content Types

Facebook's CDN served uploaded files with a content type that could be changed to text/html, and angle brackets in SRT caption files were not encoded, allowing an attacker to upload a crafted PNG containing HTML/JavaScript that would execute when served as HTML. By finding a *.facebook.com hostname pointing to the CDN, the attacker could run JavaScript in the facebook.com origin, steal the CSRF token, and perform actions on behalf of the victim.

fin1te.net

Published on fin1te.net

Content uploaded to Facebook is stored on their CDN, which is served via various domains (most of which are sub-domains of either akamaihd.net or fbcdn.net).

The author, on fin1te.net

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 CDN did not enforce a safe Content-Type header and allowed file extensions to be changed to .html, combined with insufficient encoding of angle brackets in uploaded files.

Impact

An attacker could execute arbitrary JavaScript in the context of facebook.com, steal the user's CSRF token, and perform actions on their behalf, though session cookies were HTTPOnly and direct requests to www.facebook.com were blocked.

What the attacker needed

Ability to upload files to Facebook's CDN; victim visits a crafted URL

The fix

Facebook hot-fixed the issue by removing the forward DNS entry for photo.facebook.com, but the content type issue still exists.

How it was found

  1. Upload an SRT caption file containing angle brackets to the CDN.
  2. Change the file extension to .html and observe that the file is served as text/html.
  3. Craft a PNG image with HTML/JavaScript embedded in its IDAT chunk.
  4. Upload the PNG to the advertiser library and browse to it with a .html extension.
  5. Find a *.facebook.com hostname (photo.facebook.com) that points to the CDN.
  6. Load the uploaded file via that hostname to execute JavaScript in the facebook.com origin.

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 upload a file to a website, the server usually tells your browser what kind of file it is (like an image or a text file). If the server can be tricked into saying a file is a web page, and that file contains hidden code, your browser will run that code as if it were part of the website. Here, the attacker uploaded a specially crafted image that contained a script, and because the CDN served it as a web page, the script ran in the context of Facebook's domain.

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.