Back to blog
Critical Patch Alert: Mitigating the React2Shell (CVE-2025-66478) RCE Vulnerability in Next.js
Web Security

Critical Patch Alert: Mitigating the React2Shell (CVE-2025-66478) RCE Vulnerability in Next.js

Julian Bennett

A critical Remote Code Execution vulnerability, dubbed "React2Shell," has been discovered in Next.js App Router applications. This engineering brief details the exploit mechanics regarding the Flight Protocol and provides immediate remediation steps using the fix-react2shell-next utility.

Critical Patch Alert: Mitigating the React2Shell (CVE-2025-66478) RCE Vulnerability in Next.js



The shift toward Server-Side Rendering (SSR) and React Server Components (RSC) has fundamentally changed how we architect web applications. While this model offers significant performance gains by offloading computation to the server, it also introduces complex data serialization challenges. Recently, a critical vulnerability tracked as CVE-2025-66478—and widely referred to as "React2Shell"—has been identified in the Next.js ecosystem.


This is a Remote Code Execution (RCE) vulnerability with a CVSS score of 10.0. It allows an unauthenticated attacker to execute arbitrary system commands on the server by manipulating the data stream between the client and the server. For engineering teams running Next.js 15.x or 16.x, immediate patching is mandatory.



The Mechanics of the Exploit


To understand the fix, one must understand the flaw. The vulnerability resides in the Flight Protocol, the internal specification React uses to serialize the component tree on the server and stream it to the client.


In a standard App Router request, the client sends a payload to the server to trigger a Server Action or request a re-render. The server uses react-server-dom packages to deserialize this input. The React2Shell vulnerability exploits a lack of strict type validation during this deserialization phase.


An attacker can craft a malicious multipart HTTP request that mimics a valid Server Action. However, embedded within the serialized object is a payload designed to escape the sandbox. When the server attempts to reconstruct the component tree, it inadvertently deserializes the attacker's object, triggering the execution of malicious JavaScript directly on the host machine. Because this process happens deep within the framework's internal handling of the request, standard application-level middleware (like authentication checks) is often bypassed entirely.



Automated Remediation: The fix-react2shell-next Utility


Due to the complexity of the dependency tree—where the vulnerable react-server-dom-webpack package is often a nested dependency of Next.js—manually updating package.json is prone to error. The open-source security community, in coordination with Vercel, has released a CLI utility to handle this patch deterministically.


We recommend running the fix-react2shell-next tool as the primary remediation method. This tool recursively scans your lockfiles (supporting npm, yarn, and pnpm) and forces the installation of the patched internal packages.


To patch your application interactively:

- npx fix-react2shell-next


For CI/CD pipelines (Non-interactive mode):

- npx fix-react2shell-next --fix


This command ensures that the specific "vendored" versions of React used by Next.js are upgraded to the secure release candidates, effectively closing the RCE vector.



Manual Patching Strategy


If your organizational policies prohibit the use of external patch scripts, you must perform a manual upgrade. This requires pinning your Next.js version to a release that includes the patched dependencies by default.


Ensure your package.json is updated to meet or exceed the following versions:

1) Next.js 15.0 Branch: Upgrade to v15.0.5+

2) Next.js 15.1 Branch: Upgrade to v15.1.9+

3) Next.js 16.0 Branch: Upgrade to v16.0.7+


Critical Step: After updating the version numbers, you must delete your node_modules directory and your lockfile (yarn.lock, package-lock.json, or pnpm-lock.yaml) and clean install your dependencies. A standard install command may not be sufficient to unseat the cached vulnerable versions of the internal React packages.



Engineering A "Secure by Design" Architecture


The React2Shell vulnerability serves as a stark reminder that the boundary between client and server is thinner than ever in modern frameworks. At Cognimit, we treat serialization endpoints as high-risk surfaces.


For our clients, we implement a defense-in-depth strategy:

1) Strict Content Security Policies (CSP): Limiting the sources from which scripts can be executed.

2) WAF Inspection: Configuring Cloudflare or AWS WAF to inspect incoming POST bodies for suspicious serialization tokens typical of Flight Protocol exploits.

3) Dependency Auditing: Integrating tools like Renovate to ensure patches like CVE-2025-66478 are detected and deployed within hours of disclosure.


Security is not a plugin; it is an architectural standard. Ensure your infrastructure is patched today.

TagsNext.jsReact Server ComponentsWeb SecurityRCECVE-2025-66478DevOps
WhatsAppStart a chat
Critical Patch Alert: Mitigating the React2Shell (CVE-2025-66478) RCE Vulnerability in Next.js | Cognimit