Skip to content
XSS Write-up Intermediate

Facebook XSS via Cross-Origin Resource Sharing

The Facebook Touch mobile site used the URL fragment to fetch content via AJAX and inserted it into the page without restricting the source to Facebook's own domain. An attacker could host a malicious page that loads a remote script through this mechanism, achieving cross-site scripting and taking actions as the victim on touch.facebook.com.

Matt Austin Follow

Published on maustin.net

HTML 5 does not do much to solve browser security issues. In fact it actually broadens the scope of what can be exploited, and forces developers to fix code that was once thought safe.

Matt Austin (@mattaustin), on maustin.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 client-side code took the URL fragment, made a cross-origin AJAX request to whatever address it contained, and inserted the response into the page via innerHTML without validating that the origin was Facebook's own.

Impact

An attacker could run script in the victim's touch.facebook.com session, potentially reading private data, sending messages, adding friends, and, by relaxing the domain, reaching facebook.com to take over a Facebook app owned by the user.

What the attacker needed

Victim logged in to Facebook; victim visits attacker page or link; attacker hosts a page with extra headers

The fix

The issue was fixed by Facebook after being reported.

How it was found

  1. Log in to Facebook so the touch site session is active.
  2. Create a page on an attacker-controlled server that returns content with the needed headers.
  3. Craft a touch.facebook.com URL whose fragment points to that remote page.
  4. Load the crafted URL, causing the client-side code to fetch the remote content and insert it into the page.
  5. Use an event handler in the inserted markup to load a remote script and run code in the touch.facebook.com context.
  6. Optionally set document.domain to facebook.com to interact with the main site.

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 website can load extra content into the page without a full reload, using a technique called AJAX. Here the site trusted any address placed after the # symbol in the URL and pulled that content in, even from another website. Because the content was inserted as page markup, an attacker's page could run code in the victim's Facebook session.

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 Matt Austin

View all

5 more disclosed reports, best first.

More from Meta

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.