/

CVE-2026-25802

Severity:

HIGH RISK

(7.6)

XSS in New API MarkdownRenderer Component

CVE-2026-25802

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Arbitrary JavaScript Execution in User Browser

Severity:

HIGH RISK

(7.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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.jsx component 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, direct innerHTML assignments, 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, or javascript: 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.

Sources

SourceLink
github.comgithub.com/QuantumNous/new-api/commit/ab5456eb1049aa8a0f3e51f359907ec7fff38b4b
github.comgithub.com/QuantumNous/new-api/security/advisories/GHSA-299v-8pq9-5gjq

Frequently asked

questions

Yes. If an attacker can remotely influence the LLM's output (for example, through prompts, shared documents, or integrated data sources) and that output is rendered by MarkdownRenderer.jsx, the resulting HTML can execute in the browser of any user viewing that response.

It depends on how New API is deployed. In many setups, any user who can submit prompts or data to the system may be able to influence the model output. The impact is highest when the affected UI is accessible to privileged users (such as administrators) whose sessions could be hijacked.

The safest pattern is to treat all LLM-generated content as untrusted and ensure it is either:

  • Rendered as plain text with proper HTML escaping, or
  • Sanitized through a strict allowlist-based HTML/Markdown sanitizer before being inserted into the DOM.

Additionally, avoid direct use of APIs that bypass the framework's built-in escaping unless absolutely necessary and well-guarded.

Establish a standard rendering pipeline for model output that:

  • Encodes or sanitizes content at a single, well-reviewed point.
  • Prohibits inline scripts, event handlers, and script-like URLs.
  • Is covered by automated tests that verify hostile HTML/JS payloads do not execute.

Complement this with secure coding guidelines, code review checklists focused on XSS, and automated scans looking for unsafe rendering patterns across the codebase.

Find out what's already
exploitable in your codebase.