Skip to content
Account takeover Write-up Advanced

How a $32,500 Bug Let Anyone Take Over Your Instagram — A Review of Youssef Sammouda’s Meta Pixel Hack

A Facebook endpoint forwarded attacker-controlled postMessage data to a target window, and fbevents.js trusted any message from facebook.com, allowing the attacker to make Graph API calls with their own token that included the victim's URL containing an Instagram OAuth code. The attacker could then exchange that stolen code for a first-party Instagram access token, leading to account takeover.

Vivek ps Follow

Published on osintteam.blog

Note: This article is a review and narrative analysis of a bug bounty write-up published by security researcher Youssef Sammouda (sam0). Full credit goes to the original researcher.

Vivek PS, on osintteam.blog

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 combination of a Facebook endpoint that forwarded user-supplied postMessage content to arbitrary windows and fbevents.js trusting only the origin of incoming messages without validating message structure or a nonce.

Impact

An attacker could take over any logged-in Instagram user's account with a single click, as the stolen OAuth code could be exchanged for a powerful first-party access token.

What the attacker needed

Victim clicks a link; victim logged into Instagram; attacker has a Graph Explorer token

The fix

The text says the bug was fixed within 8 days, and the second flaw was fixed quietly later; the recommended fix is to validate message types and structure and check a nonce or session token inside the message payload, not just the origin.

How it was found

  1. The attacker crafts an Instagram OAuth URL with an invalid nonce so the victim is redirected to an error page on developers.facebook.com that still loads fbevents.js.
  2. Because the victim opened the URL from the attacker's page, the error page has window.opener pointing to the attacker's page, which activates fbevents.js's message listener.
  3. The attacker's page navigates to a misconfigured Facebook endpoint, passing the attacker's Graph Explorer token and a specific message type, causing Facebook to send a postMessage to the error page window from the facebook.com origin.
  4. fbevents.js on the error page receives the message, trusts the origin, and makes Graph API requests using the attacker's token that include the page's URL containing the Instagram OAuth code.
  5. The attacker reads their own Graph Explorer API call history to retrieve the victim's Instagram OAuth authorization code.
  6. The attacker exchanges the stolen OAuth code for a first-party Instagram access token via a short-lived token exchange endpoint.

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 tracking script called fbevents.js accepted messages from any Facebook page without checking more than the sender's domain. An attacker could trick a victim into opening a link that made the script send the victim's secret login code to the attacker's own Facebook token history. The attacker then used that code to log in as the victim.

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

More by Vivek ps

View all

14 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.