Dec 1, 2026·11 min read·2 visits
React Router's unstable RSC Data and Framework modes fail to encode double-quote characters when rendering streaming redirects inside <meta http-equiv="refresh"> 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.
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 <meta http-equiv="refresh"> 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.
React Router is a widely deployed routing library and full-stack framework for React applications. Starting in version 7.11.0 and continuing into the 8.x release line, React Router introduced unstable support for React Server Components (RSC) via two primary architectures: RSC Data mode and RSC Framework mode. These modes allow applications to stream server-rendered UI components and data payloads directly to the client over an active HTTP connection.
In standard HTTP request-response lifecycles, server-side redirects are handled by returning an HTTP 3xx status code alongside a Location response header before any response body is transmitted. However, during server-side rendering (SSR) streaming in RSC architectures, the HTTP response headers (typically 200 OK with Transfer-Encoding: chunked) have already been flushed to the client before a dynamic route component or data loader throws or returns a redirect instruction. To execute a redirect after the stream has initialized, React Router falls back to enqueuing an HTML <meta http-equiv="refresh"> tag directly into the active response stream.
CVE-2026-139994 (also tracked as GHSA-mjj8-rxh9-q8f5) is a Cross-Site Scripting (XSS) vulnerability classified under CWE-79 and CWE-838 (Inappropriate Encoding for Output Context). The vulnerability occurs in packages/react-router/lib/rsc/server.ssr.tsx during the construction of this fallback <meta> tag. When interpolating the target redirect URL (renderRedirect.location or retryRedirect.location) into the double-quoted content attribute of the <meta> tag, the framework utilized the escapeHtml() helper function.
Because escapeHtml() was specifically designed to sanitize strings for serialization within HTML text nodes and <script> blocks rather than HTML attribute contexts, it failed to encode double-quote characters ("). Consequently, if an application passes user-controlled input into a redirect destination during an RSC streaming response, an attacker can include a double quote to break out of the content attribute boundary, inject malicious HTML or JavaScript handlers, and achieve arbitrary script execution in the security context of the victim's browser session.
The root cause of CVE-2026-139994 is a context mismatch between the sanitization routine applied to untrusted data and the HTML parser context in which that data is rendered. According to the HTML5 specification, the characters required to break out of a data context vary depending on whether the parser is currently in the Data state (standard HTML body text), the Script data state, or the Attribute value (double-quoted) state.
In React Router, the utility function escapeHtml() in packages/react-router/lib/dom/ssr/markup.ts was originally implemented to safely serialize state data into the DOM body and inline script tags. The implementation uses the regular expression /[&><\u2028\u2029]/g to replace ampersands (&), greater-than signs (>), less-than signs (<), and Unicode line/paragraph separators (\u2028, \u2029). While this character set is sufficient to prevent tag creation (< and >) in an HTML body context and line-termination errors in JavaScript strings, it explicitly omits quotation marks (" and ').
When routeRSCServerRequest() in packages/react-router/lib/rsc/server.ssr.tsx encounters a redirect error digest during the initial render stream (renderRedirect) or during a retry sequence (retryRedirect), it encodes the raw HTML string into a Uint8Array via TextEncoder and enqueues it onto the ReadableStreamDefaultController. The exact template string used is:
<meta http-equiv="refresh" content="0;url=${escapeHtml(renderRedirect.location)}"/>When the client browser's HTML tokenizer parses <meta http-equiv="refresh" content="0;url=, it enters the Attribute value (double-quoted) state. In this state, the tokenizer continues consuming characters as part of the content attribute value until it encounters a literal U+0022 QUOTATION MARK ("). Because escapeHtml() leaves U+0022 intact, any double quote present in renderRedirect.location immediately transitions the tokenizer to the After attribute value (quoted) state.
> [!NOTE]
> Although escapeHtml() encodes < and > into < and >—which prevents an attacker from closing the <meta> tag with > and opening a <script> tag—breaking out of the double-quoted attribute still permits the injection of arbitrary HTML attributes onto the <meta> tag itself, or the manipulation of subsequent attribute parsing depending on the surrounding DOM structure and browser behaviors.
The vulnerability and its corresponding remediation span two files inside the packages/react-router package: lib/dom/ssr/markup.ts and lib/rsc/server.ssr.tsx. Examining the code before and after the patch illustrates the exact sanitization defect and how attribute encoding resolves it.
Prior to the patch, packages/react-router/lib/dom/ssr/markup.ts exported only escapeHtml():
// Vulnerable implementation in packages/react-router/lib/dom/ssr/markup.ts
const ESCAPE_LOOKUP: { [match: string]: string } = {
"&": "\\u0026",
">": "\\u003e",
"<": "\\u003c",
"\u2028": "\\u2028",
"\u2029": "\\u2029",
};
const ESCAPE_REGEX = /[&><\u2028\u2029]/g;
export function escapeHtml(html: string) {
return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
}Notice that escapeHtml() replaces &, >, and < with JavaScript Unicode escape sequences (\u0026, \u003e, \u003c) rather than HTML character entity references (&, >, <). This confirms that escapeHtml() was originally engineered to sanitize JSON payloads embedded inside <script> tags rather than standard HTML markup attributes.
In commits c58d7152420614d6879db851aa1c74f826ddd573 (v8 branch) and e0c6b5bce96f249a71b1fc395000c6b2742c57d7 (v7 branch), the maintainers introduced a dedicated escapeAttribute() function in packages/react-router/lib/dom/ssr/markup.ts and updated both redirect streaming paths in packages/react-router/lib/rsc/server.ssr.tsx:
--- 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]);
}
+
+// Added to safely encode values placed inside double-quoted HTML attributes
+export function escapeAttribute(value: string) {
+ return value
+ .replace(/&/g, "&")
+ .replace(/"/g, """)
+ .replace(/</g, "<")
+ .replace(/>/g, ">");
+}--- 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)}"/>`,
),
);
}The introduction of escapeAttribute() properly converts & to &, " to ", < to <, and > to >. Because the HTML parser does not interpret " as an attribute delimiter when scanning inside a double-quoted attribute value, it is no longer possible to break out of the content="..." boundary in either renderRedirect or retryRedirect.
Two residual characteristics of the patch warrant consideration by developers:
escapeAttribute() does not encode single quotes (' to ' or '). Within server.ssr.tsx, the <meta> tag attributes are strictly delimited by double quotes, so the absence of single-quote encoding does not render this call site vulnerable. However, if escapeAttribute() is reused elsewhere in the codebase inside a single-quoted attribute template (attr='${escapeAttribute(val)}'), attribute breakout would be possible.escapeHtml() previously replaced &, <, and > with literal backslash-u strings (\u0026), query parameters containing & in redirect URLs were previously corrupted in <meta> tags, whereas escapeAttribute() properly preserves them as &. However, escapeAttribute() only enforces structural attribute containment; it does not validate the URL scheme inside 0;url=.... If an application passes an unvalidated, user-supplied string directly to a redirect helper without checking that it is a relative path or http:/https: URL, an attacker could supply a javascript: or data: URI inside the <meta http-equiv="refresh"> payload.Exploiting CVE-2026-139994 requires a target application to satisfy three specific prerequisites:
>= 7.11.0, < 7.18.4 or >= 8.0.0, < 8.4.0).renderRedirect or retryRedirect) whose target location string incorporates attacker-controlled input (for example, from query parameters like ?returnTo=, ?next=, or dynamic route segments).There are two primary exploitation vectors depending on how the application constructs the redirect target:
In the Vulnerable code, escapeHtml() transforms < into \u003c and > into \u003e, which prevents an attacker from closing the <meta> tag with a literal > and injecting a new <script> element. However, because " is not encoded, an attacker can terminate the content attribute and inject additional attributes directly into the <meta> element.
If an attacker supplies a payload in a reflected redirect parameter such as:
https://example.com/auth/check?returnTo=/dashboard"%20onanimationstart="alert(document.domain)"%20style="animation-name:xDuring RSC streaming, routeRSCServerRequest() generates and streams the following markup:
<meta http-equiv="refresh" content="0;url=/dashboard" onanimationstart="alert(document.domain)" style="animation-name:x"/>If the page already defines a CSS @keyframes x animation (or any existing keyframe animation name present in the application's stylesheet, such as Tailwind's spin, ping, pulse, or bounce), attaching style="animation-name:spin;animation-duration:0.01s" alongside onanimationstart or onanimationend on the <meta> tag triggers immediate JavaScript execution in modern browsers without requiring user interaction beyond visiting the link. Similarly, injecting id, name, or data-* attributes onto the <meta> tag can be leveraged for DOM Clobbering attacks against client-side scripts.
Furthermore, if the application allows arbitrary strings at the start of the redirect target (an open redirect condition) or if an attacker uses the url= directive parsing quirks of <meta http-equiv="refresh">, breaking out of or manipulating the content attribute allows overriding the refresh directive itself. Even without breaking out of the double quote, if an attacker can control the prefix of renderRedirect.location (e.g., ?returnTo=javascript:alert(document.domain)), the browser will process:
<meta http-equiv="refresh" content="0;url=javascript:alert(document.domain)"/>When the refresh timer (0 seconds) fires, browsers that permit javascript: execution in meta-refresh contexts or specific embedded webviews will execute the payload in the current origin's context.
The vulnerability carries a CVSS v3.1 base score of 4.7 (Medium) with the vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:L/A:N.
I:L) and Confidentiality impact as None (C:N), reflecting constrained DOM modification within the specific redirect flow.In practical deployment scenarios, if arbitrary JavaScript execution is achieved within the application's origin prior to navigation, the attacker gains the ability to read non-HttpOnly session cookies, extract sensitive tokens from localStorage or sessionStorage, read the current DOM state, or issue authenticated fetch()/XMLHttpRequest calls to backend APIs on behalf of the victim user.
The scope of affected installations is naturally constrained by the fact that React Server Components (RSC) Data mode and RSC Framework mode are designated as unstable features in React Router v7 and v8. Applications using standard React Router client-side routing, standard SSR framework mode (non-RSC), or standard HTTP 3xx header redirects are not affected by this code path.
To remediate CVE-2026-139994, organizations utilizing React Router's unstable RSC modes should upgrade to the patched releases immediately.
react-router and all aligned @react-router/* packages to version 7.18.4 or later.react-router and all aligned @react-router/* packages to version 8.4.0 or later.# For v7.x installations
npm install react-router@^7.18.4
# For v8.x installations
npm install react-router@^8.4.0If an immediate framework upgrade is not feasible, or to harden applications against both XSS and Open Redirect vulnerabilities even after patching, implement the following controls:
redirect() calls. Validate that all dynamic redirect targets are strictly local relative paths that start with a single forward slash (/) and do not start with // or \, and reject or strip any URL containing double quotes ("), whitespace, or control characters:function getSafeRedirectUrl(target: string | null, fallback = "/"): string {
if (!target || typeof target !== "string") return fallback;
// Ensure target starts with a single '/' and contains no quotes or protocol schemes
if (!target.startsWith("/") || target.startsWith("//") || target.startsWith("/\\")) {
return fallback;
}
if (target.includes('"') || target.includes("'") || /[\r\n\t]/.test(target)) {
return fallback;
}
return target;
}'unsafe-inline' from script-src and using cryptographic nonces or hashes). When inline event handlers like onanimationstart are injected via attribute breakout, a nonce-based or strict script-src policy instructs the browser to block the execution of the inline event handler.CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:L/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
react-router Remix Software / Shopify | >= 7.11.0, < 7.18.4 | 7.18.4 |
react-router Remix Software / Shopify | >= 8.0.0, < 8.4.0 | 8.4.0 |
| Attribute | Detail |
|---|---|
| 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 |
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. Furthermore, it maps to CWE-838 (Inappropriate Encoding for Output Context) due to the application of an HTML body encoding routine within a double-quoted HTML attribute value.
CVE-2026-139996 is a prototype pollution vulnerability (CWE-1321) in React Router's vendored turbo-stream deserializer, utilized in Framework mode for single-fetch transitions and client-server hydration. When unflattening serialized streams, the decoder assigns object properties using direct bracket notation (object[key] = value) rather than defining own properties via Object.defineProperty. Furthermore, the deserializer lacks integer and bounds validation on stream reference indices. An attacker capable of supplying crafted turbo-stream payloads to the deserializer can pollute Object.prototype or trigger arbitrary index dereferences, compromising application integrity and confidentiality.
CVE-2026-137181 (GHSA-637h-v79h-mvqf) is an incorrect authorization vulnerability (CWE-863) in OpenFGA versions 1.10.3 through 1.22.x. The graph evaluation engine fails to distinguish between normal stream exhaustion and context cancellations or deadline exceedances during concurrent set evaluations. When resolving models using relational set operations (and, or, but not), an aborted worker branch can be evaluated as empty rather than errored, causing the engine to return unauthorized access grants (Allowed: true). When query caching is enabled, these erroneous evaluation states can be persisted to the in-memory cache, poisoning subsequent authorization checks.
An uncaught exception vulnerability (CWE-248) in Engine.IO versions prior to 6.6.12 allows remote unauthenticated attackers to cause a Denial of Service (DoS) against Node.js applications utilizing Engine.IO or Socket.IO. By sending an HTTP upgrade request targeting a non-Engine.IO URL path and forcibly resetting the underlying TCP connection before the internal destruction timeout expires, an attacker triggers an unhandled ECONNRESET error event on the socket object, terminating the entire Node.js runtime process.
CVE-2026-137199 (GHSA-ghv9-86vm-4v8m) is a critical OS command injection vulnerability in the Node.js cross-spawn library affecting versions prior to 6.0.7 and 7.1.0 on Windows. The vulnerability stems from incomplete metacharacter escaping when routing batch scripts (.bat and .cmd) outside of node_modules/.bin through cmd.exe, alongside flaws in file extension canonicalization, environment variable expansion, and line break handling. Attackers who control arguments passed to batch scripts can break out of argument quoting and execute arbitrary system commands.
An improper data encoding vulnerability (CWE-172) exists in the OpenTelemetry Collector exporterhelper package between versions 0.147.0 and 0.163.x. When metadata-partitioned batching is enabled with multiple metadata keys, the partition key generator uses an unescaped null byte delimiter to concatenate key names and multi-valued header arrays. An authenticated attacker capable of sending multi-valued HTTP or gRPC headers to an ingress receiver can induce partition key collisions, causing cross-tenant telemetry data mixture, data poisoning, or unauthorized data exfiltration.
CVE-2026-137187 (GHSA-5xhm-p3jx-2fmc) is a missing authorization vulnerability (CWE-862) in @zereight/mcp-gitlab affecting versions 2.2.5 through 2.3.6. The flaw exists within the gitlab_api_request tool, where project allowlist enforcement fails open when evaluating API paths that do not conform to the /projects/:id pattern or when following HTTP redirects to an empty relative path. Attackers or compromised LLM agents with access to the api toolset can bypass project isolation boundaries to query or modify group, user, and instance-level GitLab resources permitted by the server's underlying authentication token.