TanStack Markdown has safe defaults, but it is not a general HTML sanitizer.
By default:
Relative URLs, fragments, HTTP, HTTPS, email, and telephone links remain available. Other explicit protocols, including data:, are removed.
allowHtml: true is an explicit trusted-content boundary:
renderHtml(source, { allowHtml: true })The HTML renderer emits raw nodes directly. The React and Octane renderers use dangerouslySetInnerHTML. Do not enable this option for untrusted user content unless the result is sanitized with a policy appropriate for your application.
A highlighter returns HTML that is inserted into <code> without further escaping:
renderHtml(source, { highlighter })Only use a highlighter that escapes source code and returns trusted markup. TanStack Markdown cannot distinguish token markup from an injection in the returned string.
The tested TanStack Highlight adapter returns escaped inner token markup without duplicating Markdown's <pre><code> containers.
An extension renderHtml hook also returns trusted HTML. React and Octane component replacements can enforce application-specific link, image, and navigation policies, but those replacements are outside core renderer parity.
Renderers trust document ASTs supplied directly by the application. URL screening happens during Markdown parsing, not when rendering an arbitrary link or image node. Do not accept untrusted JSON as a document AST without validating its structure and applying your URL and HTML policies.
The core limits parser nesting and inline delimiter scans. These are not a limit on total input size, footnote count, or work performed by extensions. Bound untrusted document sizes in the application, and batch streaming updates instead of rerendering on every incoming character.
For user-generated Markdown:
The security regression suite covers executable protocols, raw HTML opt-in behavior, escaping, and framework renderer handling.