Skip to content
XSS Write-up Advanced

Self‑XSS in Facebook Payments Flow Leading to Account Takeover

A cross-window message handler on a Facebook payments page trusted messages from a third-party payment provider and injected their HTML without sanitisation. By first exploiting an XSS in that provider, an attacker could execute JavaScript on facebook.com and escalate to account takeover.

Youssef Sammouda Follow

Published on ysamm.com

Bounty$62,500 View original

Facebook’s payments and billing flows rely heavily on third-party financial service providers. To facilitate bank-based payments, Facebook embeds external services inside privileged Facebook pages and allows cross-window communication between those services and facebook.com.

Youssef Sammouda, on ysamm.com

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

The Facebook page validated the message origin but then inserted the message payload into the DOM without sanitisation, so any XSS in the trusted third-party origin became an XSS on facebook.com.

Impact

The attacker could take over Facebook, Instagram and Workplace accounts by getting a victim to visit a malicious website, and could also compromise any user adding a payment method if the third-party provider were compromised.

What the attacker needed

Victim visits attacker website; victim is logged into Facebook; attacker has a valid nonce and user_id; login CSRF forces victim into attacker account

The fix

The text states the bug was fixed by Facebook, but does not describe the fix; it should sanitise or avoid injecting HTML from cross-window messages.

How it was found

  1. Force the victim to log into the attacker's Facebook account via login CSRF.
  2. Load the ACH initialisation page with a valid attacker nonce and user_id.
  3. Facebook embeds ThirdPartyPaymentProvider.com inside a privileged iframe.
  4. An XSS in ThirdPartyPaymentProvider.com allows attacker-controlled JavaScript execution.
  5. The compromised iframe sends a ThirdPartyPaymentProvider.learnMore message to the parent window.
  6. Facebook injects attacker-supplied HTML, triggering XSS on facebook.com.

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 Facebook page for setting up bank payments embedded another company's website in a frame and listened for messages from it. It checked the message came from the right website but then put the message's HTML straight onto the page without cleaning it. If an attacker could run code on that other website, they could send malicious HTML that Facebook would render, giving them control of the Facebook page.

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 Youssef Sammouda

View all

4 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.