Summary
Certain SPA navigation flows in React Router and Remix can turn unsafe redirect URLs into executable JavaScript on the client, enabling cross-site scripting (XSS).
The issue arises when redirect URLs in Framework/Data/RSC modes are derived from untrusted input or open redirects, allowing attackers to inject script-capable URLs that the router follows in the browser context.
Affected context
This vulnerability appears in applications using:
@remix-run/routerprior to 1.23.2react-routerversions 7.0.0 through 7.11.0- Remix v1/v2 when using Framework Mode, Data Mode, or unstable RSC modes
It affects scenarios where redirect destinations are:
- Built from untrusted content (e.g., query params, request data, external inputs)
- Influenced by open redirects or unvalidated external URLs
Applications using Declarative Mode (<BrowserRouter>) exclusively are not impacted by this specific issue.
Exploit preconditions
- Attack surface: Browser-based navigation within React/Remix SPAs.
- Required access: Ability to influence redirect targets, typically via:
- User-controlled input (query parameters, form fields, headers, or body data)
- External links or open redirect endpoints feeding into router redirects.
- Trigger point: A loader or action in Framework Mode, Data Mode, or unstable RSC mode issues a redirect using a URL that contains attacker-controlled content.
- Why exploitation is possible: The router trusts the computed redirect path and forwards the browser to that location without sufficiently validating or constraining the URL scheme/domain, allowing script-capable or XSS-bearing URLs to execute in the client context.
Why this happens
The root cause is insufficient validation and normalization of redirect URLs before they are used for client-side navigation, combined with the powerful control that loaders and actions have over SPA routing.
In the vulnerable modes, redirect paths can be constructed from untrusted values without enforcing strict constraints such as:
- limiting to same-origin, application-internal paths
- disallowing dangerous URL schemes
- sanitizing or rejecting malformed URLs
This maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting), because untrusted input flows into a navigation mechanism that ultimately leads the browser to execute attacker-influenced JavaScript or markup as part of the client experience.
Potential impact
- Execution of arbitrary JavaScript in the victim's browser.
- Theft of session tokens, API tokens, or other credentials accessible to the SPA.
- Account takeover through malicious actions performed on behalf of the user.
- Unauthorized access to or modification of data exposed through the SPA's APIs.
- Phishing flows and UI redressing using attacker-controlled pages opened from trusted origins.
- Lateral movement to other application areas through authenticated client-side actions.
General mitigation guidance
Effective mitigation relies on controlling how redirect URLs are constructed and where they are allowed to point:
- Prefer strictly internal navigation: restrict redirects from loaders/actions to relative, application-local paths instead of arbitrary URLs.
- Apply allowlist-based validation on any redirect target built from user input, limiting to known-good paths or identifiers rather than raw URLs.
- Normalize and validate URL components (path, query, fragment) independently instead of concatenating raw strings.
- Avoid passing opaque, user-supplied URLs directly to router redirect APIs; instead, map user choices to predefined routes or route IDs.
- Enforce origin and scheme checks so that navigation stays within HTTPS and trusted domains only.
- Design redirect logic so that redirects are not dependent on untrusted content where possible; prefer stable, server-controlled routing decisions.
These patterns reduce the chance that untrusted data will control client-side navigation in a way that can lead to XSS.
How teams detect issues like this
Detection involves tracing how redirect URLs are constructed and consumed:
- Static analysis / code scanning:
- Flag usage of router redirect APIs where arguments are derived from request data, query strings, or other untrusted sources.
- Detect string concatenation or template literals that build URLs using unvalidated user input.
- Identify places where full URLs (with schemes and domains) are allowed, rather than restricted route paths.
- Code review signals:
- Redirect logic in loaders or actions that references
request.url,searchParams,location, or user-provided fields without validation. - Conditional navigation that trusts parameters like
redirectTo,returnUrl, ornextwithout checking origin or route membership. - Custom wrappers around React Router / Remix redirect helpers that do not enforce origin or scheme constraints.
- Policy enforcement:
- Introduce project-wide guidelines that all redirect targets must be:
- relative paths, or
- enumerated route names/IDs mapped on the server side.
- Integrate automated review tools or linters to enforce these rules in CI.
Combining targeted static checks with focused code review on routing and redirect flows helps surface similar issues early.

