
浅谈React Server Components RCE 漏洞分析
In the past couple of days, there has been widespread discussion about a deserialization RCE vulnerability in React. The official CVSS score is a full 10.0, on par with Log4j. Rumors quickly spread claiming it is the "Log4j of modern frontend," causing panic among developers at many companies. People woke up to find themselves searching through documentation and applying patches... At the same time, there have also been many voices of doubt online. Some tested the vulnerability and found it is not as severe as advertised; instead, exploitation requires certain conditions. So I decided to take the time to study this vulnerability in depth.
react-server-dom-webpack < 19.2.0, react-server-dom-turbopack < 19.2.0The vulnerability arises because in [email protected], the key function requireModule (pseudocode) for parsing Server Action on the server side:
function requireModule(metadata) {
var moduleExports = __webpack_require__(metadata[0]);
// ...
return "*" === metadata[2]
? moduleExports
: "" === metadata[2]
? moduleExports.__esModule
? moduleExports.default
: moduleExports
: moduleExports[metadata[2]]; // ← 漏洞点
}
The core issue is in the part moduleExports[metadata[2]]. There is no validation of metadata[2], allowing the attacker to not only access the module's own exported properties but also properties on the prototype chain (such as constructor, __proto__, etc.). When the attacker crafts metadata[0] (e.g., pointing it to vm), they can then craft metadata[2] to export dangerous methods from the specified module, such as vm.runInThisContext, thereby achieving exploitation.
In my analysis, I referred to the test environment and exploit provided by ejpir, taking the vm_runInThisContext Code Execution gadget as an example. The process is as follows (note: under real-world conditions, the exploitation process may differ!):
First, after sending a request with the payload, breakpoint at the location where the request is received:


Then the program executes to const formData = parseMultipart(buffer, boundaryMatch[1]);. Step into parseMultipart:

parseMultipart extracts the request body data and returns it to formData:

Step into const actionFn = await decodeAction(formData, serverManifest); Vulnerability trigger point:

Step into loadServerReference:


**Now we reach the core vulnerable code location requireModule. Step into it:


It returns the parts before and after # in the id value as module and method, and the bound parameter value as the method argument:




Step into actionFn to execute the final payload:



At this point, the exploit is complete!
This vulnerability is fundamentally caused by insufficient input validation, much like Log4j and fastjson. In my test above, I used vm_runInThisContext. In reality, there are multiple gadgets that can be exploited, such as:
vm#runInThisContextvm#runInNewContextchild_process#execSyncchild_process#execFileSyncchild_process#spawnSyncfs#readFileSyncfs#writeFileSync#constructor#__proto__#prototypeAttackers can use this vulnerability to achieve:
vm#runInThisContext or child_process#execSyncfs#readFileSync, fs#writeFileSync.bashrc, overwrite application files, etc..env, private keys, database credentials, etc.)Based on this, the following defense measures can be taken:
For temporary defense, the following angles can be considered. Configure rules on a WAF to intercept these dangerous fields, thereby blocking malicious attacks in a timely manner. Additionally, matching and interception can be performed on nginx, as shown below:
# Nginx 配置示例
location /formaction {
# 拦截包含危险模块引用的请求
if ($request_body ~* "(vm#|child_process#|fs#|module#)") {
return 403;
}
# 拦截原型链污染尝试
if ($request_body ~* "(#constructor|#__proto__|#prototype)") {
return 403;
}
}
The official security update has been released. Upgrade to a secure version immediately!:
# Upgrade react-server-dom-webpack
npm install react-server-dom-webpack@>=19.2.0
# Upgrade react-server-dom-turbopack
npm install react-server-dom-turbopack@>=19.2.0
# For Next.js users
npm install next@>=15.0.5
Fixed Versions:
react-server-dom-webpack: >= 19.2.0react-server-dom-turbopack: >= 19.2.0next.js: >= 15.0.5During my analysis of the above vulnerability, I referenced the exploit by whiteov3rflow, further wrote a vulnerability detection tool for the test environment, and placed it in a GitHub repository.

Students who need to self-check can visit to obtain it (note: due to the original author's test environment, it may currently only be applicable to the original test environment; further improvements are pending. Those who need it can also modify it themselves...). Please use it with legal authorization and refrain from unauthorized destructive actions!
As of now, 2025.12.5, what I have seen online is that the "wind" around this vulnerability fluctuates like a roller coaster. At times it is a "nuclear bomb," then a "water hole," then back to a "nuclear bomb"... Related exploitation methods are emerging endlessly. Based on current information, it is possible that the "nuclear bomb" label will stick, though its scope of influence is relatively smaller than Log4j. Regardless, all involved parties should update as soon as possible to eliminate future risks!!!
Also, a security admonition for developers: Never trust user input. Log4j, fastjson, and the current React RCE all fell victim to this. Therefore, in actual business development, dangerous positions must be strictly validated using sandboxes or whitelists to prevent tragedies!!!
What you get from books is shallow; to truly understand, caution must be exercised.