Dev.to Security 🔐 Cybersecurity 👁 0 📖 3 min read

CVE-2026-139994: CVE-2026-139994: Cross-Site Scripting via Context-Mismatched HTML Escaping in React Router RSC Streaming…

CVE-2026-139994: Cross-Site Scripting via Context-Mismatched HTML Escaping in React Router RSC Streaming Redirects Vulnerability ID: CVE-2026-139994 CVSS Score: 4.7 Published: 2026-12-01 CVE-2026-139994 (GHSA-mjj8-r

CVE-2026-139994: Cross-Site Scripting via Context-Mismatched HTML Escaping in React Router RSC Streaming Redirects

Vulnerability ID: CVE-2026-139994
CVSS Score: 4.7
Published: 2026-12-01

CVE-2026-139994 (GHSA-mjj8-rxh9-q8f5) is a Cross-Site Scripting (XSS) vulnerability in React Router affecting versions 7.11.0 through 7.18.3 and 8.0.0 through 8.3.1. The flaw resides in the server-side streaming handler for the unstable React Server Components (RSC) Data mode and RSC Framework mode. When a server-side redirect is triggered during an HTML stream, the framework injects an inline element into the response stream. Because the redirect destination URL is sanitized using an HTML body escaping utility (escapeHtml) rather than an attribute-specific encoding function, double-quote characters (") are left unescaped. An attacker who can influence the redirect URL can break out of the content attribute context, inject arbitrary attributes or HTML elements, and execute arbitrary JavaScript within the victim's browser session.

TL;DR

React Router's unstable RSC Data and Framework modes fail to encode double-quote characters when rendering streaming redirects inside tags. Applications that incorporate user-controlled input into redirect destinations are vulnerable to reflected Cross-Site Scripting (XSS). Upgrade to React Router 7.18.4 or 8.4.0 to resolve the issue.

Technical Details

  • Vulnerability Type: Cross-Site Scripting (CWE-79 / CWE-838)
  • Affected Component: React Router Unstable RSC Data & Framework Modes (server.ssr.tsx)
  • CVSS v3.1 Score: 4.7 Medium (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:L/A:N)
  • Attack Vector: Network (Reflected via Attacker-Controlled Redirect Target)
  • Affected Versions: >= 7.11.0, < 7.18.4 and >= 8.0.0, < 8.4.0
  • Patched Versions: 7.18.4 and 8.4.0
  • Exploit Status: No known public exploits in the wild
  • CISA KEV Status: Not Listed

Affected Systems

  • react-router
  • create-react-router
  • @react-router/dev
  • @react-router/node
  • @react-router/serve
  • @react-router/express
  • @react-router/cloudflare
  • @react-router/architect
  • @react-router/fs-routes
  • @react-router/remix-routes-option-adapter
  • react-router: >= 7.11.0, < 7.18.4 (Fixed in: 7.18.4)
  • react-router: >= 8.0.0, < 8.4.0 (Fixed in: 8.4.0)

Code Analysis

Commit: c58d715

Use escapeAttribute instead of escapeHtml for redirect locations in RSC SSR streaming (main / v8 branch)

--- a/packages/react-router/lib/dom/ssr/markup.ts
+++ b/packages/react-router/lib/dom/ssr/markup.ts
@@ -17,3 +17,11 @@ const ESCAPE_REGEX = /[&><\u2028\u2029]/g;
 export function escapeHtml(html: string) {
   return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
 }
+
+export function escapeAttribute(value: string) {
+  return value
+    .replace(/&/g, "&amp;")
+    .replace(/"/g, "&quot;")
+    .replace(/</g, "&lt;")
+    .replace(/>/g, "&gt;");
+}
--- a/packages/react-router/lib/rsc/server.ssr.tsx
+++ b/packages/react-router/lib/rsc/server.ssr.tsx
@@ -19,7 +19,7 @@ import {
   decodeRedirectErrorDigest,
   decodeRouteErrorResponseDigest,
 } from "../errors";
-import { escapeHtml } from "../dom/ssr/markup";
+import { escapeAttribute } from "../dom/ssr/markup";

 const defaultManifestPath = "/__manifest";

@@ -282,7 +282,7 @@ export async function routeRSCServerRequest({

           controller.enqueue(
             new TextEncoder().encode(
-              `<meta http-equiv="refresh" content="0;url=${escapeHtml(renderRedirect.location)}"/>`,
+              `<meta http-equiv="refresh" content="0;url=${escapeAttribute(renderRedirect.location)}"/>`,
             ),
           );
         }
@@ -428,7 +428,7 @@ export async function routeRSCServerRequest({

             controller.enqueue(
               new TextEncoder().encode(
-                `<meta http-equiv="refresh" content="0;url=${escapeHtml(retryRedirect.location)}"/>`,
+                `<meta http-equiv="refresh" content="0;url=${escapeAttribute(retryRedirect.location)}"/>`,
               ),
             );
           }

Commit: e0c6b5b

Backport escapeAttribute fix for RSC SSR streaming meta refresh redirects (v7 branch)

Mitigation Strategies

  • Upgrade React Router and associated @react-router/* packages to the patched versions (7.18.4 or 8.4.0).
  • Enforce strict allowlist validation on all user-supplied redirect destinations (e.g., returnTo, redirect_uri) to ensure only relative paths without double-quote characters are passed to redirect helpers.
  • Implement a strong Content Security Policy (CSP) that restricts inline event handler execution (disallowing 'unsafe-inline' in script-src).

Remediation Steps:

  1. Audit package.json and lockfiles (package-lock.json, yarn.lock, pnpm-lock.yaml) to check if react-router is between 7.11.0 and 7.18.3, or between 8.0.0 and 8.3.1.
  2. Verify whether the application uses the unstable RSC Data mode or RSC Framework mode (routeRSCServerRequest).
  3. Run npm update or yarn upgrade to bump react-router and all @react-router/* packages to >= 7.18.4 (for v7) or >= 8.4.0 (for v8).
  4. Review all application loaders and server actions that invoke redirect() with user-supplied parameters and add input sanitization to reject non-relative URLs and quotation marks.

References

Read the full report for CVE-2026-139994 on our website for more details including interactive diagrams and full exploit analysis.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.