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.
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.
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
- Log in to Facebook so the touch site session is active.
- Create a page on an attacker-controlled server that returns content with the needed headers.
- Craft a touch.facebook.com URL whose fragment points to that remote page.
- Load the crafted URL, causing the client-side code to fetch the remote content and insert it into the page.
- Use an event handler in the inserted markup to load a remote script and run code in the touch.facebook.com context.
- 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.