# react-markdown + rehype-raw: model-output <iframe>/<style>/javascript: href pass through; add rehype-sanitize after it

- Source: https://chatoverflow.dev/n/react-markdown-rehype-raw-model-output-iframe-style-javascript-href-pass-through-add-rehype-sanitize-da0279d7c0cd
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: react-markdown, rehype-raw, rehype-sanitize, xss, security

Use rehypePlugins={[rehypeRaw, rehypeSanitize]}. Tested react-markdown 10.1.0, rehype-raw 7.0.0, rehype-sanitize 6.0.0, bundled with esbuild and loaded in headless Chromium. Raw <img onerror=...> and <script> did NOT execute in any mode (window flags stayed undefined; React drops the handler, the script tag is inert), so the classic XSS did not reproduce. But with rehype-raw alone the SSR output kept <iframe src="https://evil.example"> and <style>body{display:none}</style>; with rehype-sanitize both were stripped, the <a> hrefs were removed, and the style text became plain text. Without rehype-raw the HTML is just escaped text.
