# XSS from Mastodon embeds

Malicious Mastodon server returned a javascript: URL in toot metadata, which IRCCloud used as an iframe src, executing JS in the parent context to steal session cookies.

- Payout: $500
- Severity: high
- Program: IRCCloud
- Found by: lotsofloops
- Disclosed: 2023-10-09
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1887917
- Library page: https://bugbountylibrary.com/r/h1%3A1887917
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:high tech:rest technique:recon vuln:xss

**Target:** IRCCloud web client Mastodon embed renderer (api/v1/statuses fetch + iframe src)
**Root cause:** The web client trusted the `url` field from an attacker-controlled Mastodon API response and used it directly as an iframe `src`, without validating the scheme, allowing `javascript:` URLs.
**Steps:**
1. Enable 'Embed social media links' in Chat & embeds settings.
2. Send a message containing a toot-looking URL like `https://sm4.ca/@a/123456789012345678`.
3. Attacker serves `https://sm4.ca/api/v1/statuses/123456789012345678` returning JSON with `account.url` matching the link and `url` set to `javascript:top.document.body.innerHTML = "hi your cookie is " + document.cookie;//`.
4. Web client fetches the status, builds an iframe with the returned `url` as src (appending `/embed`, neutralized by trailing `//`).
5. javascript: URL executes in a document with access to the parent, reading `document.cookie`.
**How found:** Researcher reasoned that since anyone can host a Mastodon server, the API response is attacker-controlled; inspected how the client builds the embed iframe and noticed the `url` field is used as `src` without scheme validation, then crafted a javascript: URL.
**Exploitation:** Attacker runs a Mastodon instance, posts a crafted status whose API response contains a javascript: URL, and sends the toot link into a channel. Any web client user with embeds enabled auto-fetches the status and executes the payload, exfiltrating their session cookie. Broadcasting to a large channel compromises many users at once.
**Escalation:** Sending the malicious link to a large channel scales the attack to mass account takeover.
**Insight:** When a client fetches metadata from an attacker-selectable third-party server and uses a returned URL as an iframe/img src, test scheme injection (javascript:, data:) — and note appended path suffixes like `/embed` can be neutralized with a trailing `//` comment.

