Summary
A Cross-Site Scripting (XSS) vulnerability in New API's MarkdownRenderer.jsx component allows untrusted model output to be rendered as active <script> content in the browser.
When an LLM returns HTML containing script tags and this output is injected into the page without proper sanitization, an attacker-controlled response can execute arbitrary JavaScript in the context of the consuming application.
Affected context
This vulnerability affects deployments of New API that:
- Use the
MarkdownRenderer.jsxcomponent to display model responses in a web UI - Render LLM output as HTML or Markdown without robust sanitization or HTML escaping
- Allow user input, prompts, or third-party data to influence what the model generates
The risk is elevated in multi-user or shared environments where model output can be viewed by other users or administrators.
Exploit preconditions
- Attack surface: Web frontend that renders LLM/Markdown output using
MarkdownRenderer.jsx. - Required access: Ability to influence the LLM's generated content (e.g., by submitting prompts, providing context, or controlling upstream data sources).
- Trigger point: The application takes the LLM response containing
<script>or other dangerous HTML and renders it directly into the DOM. - Why exploitation is possible: The rendering pipeline treats model output as trusted HTML/Markdown and does not sufficiently sanitize or neutralize active script content before insertion into the page.
Why this happens
The underlying issue is a classic Cross-Site Scripting (CWE-79) pattern where untrusted content is injected into a web page without proper encoding or sanitization.
In this case, the MarkdownRenderer.jsx component relies on a rendering path that allows raw HTML, including <script> tags, to be interpreted by the browser.
Because LLM output is inherently untrusted and can be influenced by user-provided prompts or data, treating it as safe HTML creates a channel for arbitrary script execution.
The bug is not about Markdown itself, but about failing to enforce a strict separation between data (text) and executable content (scripts) in the rendering logic.
Potential impact
- Execution of arbitrary JavaScript in the victim's browser when viewing rendered model output
- Theft of session tokens, API keys stored in web storage, or other sensitive browser-accessible data
- Unauthorized actions performed on behalf of a logged-in user (e.g., changing settings, triggering administrative operations)
- Defacement or manipulation of the UI to mislead users or hide malicious behavior
- Pivoting to other vulnerabilities in the same origin via DOM manipulation or script injection
General mitigation guidance
Effective mitigation focuses on treating all LLM-generated content as untrusted and enforcing strict output encoding:
- Render model output as plain text by default, escaping HTML special characters before inserting into the DOM.
- If HTML/Markdown rendering is required, pass content through a well-maintained, configurable HTML sanitizer that:
- Strips
<script>, event handlers (e.g.,onload,onclick),javascript:URLs, and other active content. - Optionally enforces a strict allowlist of safe tags and attributes.
- Avoid direct usage of dangerous APIs such as
dangerouslySetInnerHTML(React) or equivalent unless content is sanitized and the usage is carefully constrained. - Apply a defense-in-depth approach by combining client-side sanitization with server-side checks on stored or shared content.
- Minimize privileges available to frontend sessions (e.g., avoid unnecessary powerful actions from a single page) so that XSS impact is reduced.
How teams detect issues like this
Organizations can detect similar vulnerabilities using a combination of automated and manual techniques:
- Static analysis and linting:
- Rules that flag uses of
dangerouslySetInnerHTML, directinnerHTMLassignments, or equivalent DOM sinks where the source is model output or other untrusted data. - Checks for JSX/React patterns that bypass escaping, especially in reusable rendering components like Markdown renderers.
- Code review signals:
- Components that render Markdown or HTML without clear, centralized sanitization logic.
- Any code path that assumes LLM responses are "safe" or treats them as trusted templates.
- Dynamic and security testing:
- Fuzzing or test cases that feed model prompts designed to produce HTML with
<script>, event attributes, orjavascript:URLs, and verifying that scripts do not execute. - Browser-based security testing tools configured to detect reflected or stored XSS in pages showing LLM responses.
- Policy enforcement:
- Development guidelines requiring explicit sanitization for all rich-text or HTML-rendering components.
- CI/CD checks that block merges when unsafe rendering APIs are used without documented sanitization.

