[bug] Chat renders raw HTML from messages, so a message can redirect the app window
The bug
When I send a chat message that contains HTML, the chat doesn't show it as text. It turns it into real page elements. A <meta http-equiv="refresh"> tag in a message takes the whole Screenpipe window to another website a few seconds later, and there's no way back inside the app. <iframe>, <form>, <object>, <embed>, <style> and inline style= render as live elements too.
This matters because most chat text isn't typed by the user. AI replies are built from captured screens, web pages and files, so any HTML the AI repeats from that content becomes live in the app window. That lets outside content show fake UI, send requests, or redirect the window, and the app has no CSP to block it ("csp": null in src-tauri/tauri.conf.json:123).
Cause, as far as I can tell from the code:
components/chat/markdown-block.tsx:262renders every message withrehypePlugins={[rehypeRaw]}.rehype-rawturns raw HTML in markdown into real elements.- Nothing sanitizes it afterwards.
rehype-sanitizeisn't installed, so every tag and attribute passes through. - User and assistant messages go through the same renderer (
markdown-block.tsx:81), so sending a message is enough to trigger it, with no AI reply needed. - Raw HTML can't just be turned off, because the system prompt asks the AI to write
<details><summary>collapsibles (lib/chat/system-prompt.ts:112).
expected
Safe formatting like <details>, <b>, <kbd>, <sub>/<sup> and tables keeps rendering. Tags and attributes that can navigate, submit, embed or restyle the app (<meta>, <iframe>, <form>, <object>, <embed>, <base>, <style>, style=, on*=, javascript: links) are removed before they reach the page.
actual
All of them render as live elements, and the <meta refresh> message below takes the whole app window to example.com.
steps to reproduce
cd apps/screenpipe-app-tauri && bun run dev:tauri- Open chat and send this message. You don't need an AI provider, because your own message bubble renders it:
<p><b>REDIRECT TEST</b>: if this line is bold, raw HTML is live. The window leaves in 3 seconds.</p> <meta http-equiv="refresh" content="3;url=https://example.com/?screenpipe-redirect-test"> <form action="https://example.com/?screenpipe-form-test"><button>Form test: click me</button></form> - About 3 seconds later, the whole Screenpipe window turns into example.com. Links on that page keep navigating inside the app window.
- For a quicker visual check, send
<iframe srcdoc="<h1 style='color:red'>INJECTED</h1>"></iframe>. A red "INJECTED" heading appears inside the message bubble.
https://github.com/user-attachments/assets/c8f8198f-faed-4527-9331-a59b8fdb04dd
system info
- os: macOS 27.0
- screenpipe version: 2.7.75 (built from source,
mainat ba342ea48, native app viabun run dev:tauri)
Source: screenpipe/screenpipe