Skip to content
XSS Write-up Advanced

PostMessage Misconfiguration + AI Prompt Injection + Sandbox Escape = XSS & Data Exfiltration

A sandboxed preview iframe on an AI assistant platform accepted postMessage input without checking the sender's origin and sent data back with a wildcard target origin. By chaining this with an AI prompt that forces HTML rendering and a window.name trick to reach the iframe from an attacker page, an attacker could run script inside the iframe and continuously steal the contents of the victim's AI conversation pages.

infosecwriteups.com

Published on infosecwriteups.com

When three individually medium-severity issues chain together to compromise an AI assistant platform.

Source_To_Sink, on infosecwriteups.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

Likely the preview iframe's postMessage handlers trusted any sender and used a wildcard target origin, so the sandbox's isolation was undermined by an open message channel.

Impact

An attacker could run script inside the sandboxed preview and continuously exfiltrate sensitive content from the victim's AI conversations, though the text notes the sandbox still blocks cookies, storage, top navigation and popups.

What the attacker needed

Victim clicks a fake login button; victim is logged in to the AI platform; popups allowed by the browser

The fix

The text gives recommended fixes rather than saying they were deployed: validate event.origin on incoming messages, use explicit target origins, sanitise rendered HTML, and set Cross-Origin-Opener-Policy to same-origin to break the opener link.

How it was found

  1. The victim opens the attacker's first page, which sets a window name and shows a fake Login button.
  2. Clicking the button opens the attacker's second page in a new window.
  3. The second page opens the AI platform chat URL with a query that makes the AI render an HTML preview, reusing the named window.
  4. The second page reaches the sandboxed preview iframe through the opener's frame list and sends a crafted start-received message containing a script tag.
  5. The iframe renders the HTML without an origin check, so the script runs and reads page content from the opener's frames.
  6. The script sends the stolen content back to the attacker page through a wildcard postMessage, repeating on an interval.

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 web page can talk to another page or frame inside it using a browser feature called postMessage. The receiving side is supposed to check who sent the message, and the sending side is supposed to name the exact site allowed to receive it; here neither check was done. Separately, the AI could be asked to turn content into HTML, and a browser quirk called window.name let the attacker's page keep a handle on the victim's window, so the attacker could push a script into the preview frame and read the conversation.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

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.