React2Shell: How React Server Components Turned into RCE
A deserialisation flaw in React Server Components lets a crafted request rebuild executable objects and reach the JavaScript Function constructor, so an attacker can run commands on the server. Next.js is the main target because Server Actions are enabled by default and a single request with the right headers reaches the vulnerable path.
medium.com
Published on medium.com
React Server Components rely on serialization and deserialization to transfer complex data between client and server.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the RSC deserialiser rebuilt objects from client-controlled input without restricting prototype paths and constructor references, allowing reach to the Function constructor.
Impact
An attacker could execute arbitrary commands on the server, leading to secret theft, cryptomining, backdoors and full cloud compromise; the text notes exploitation was less scalable on frameworks other than Next.js.
What the attacker needed
Next.js with Server Actions; a crafted request with correct headers; no app knowledge needed
The fix
React and affected frameworks should be patched, RSC endpoints treated as public and hostile, strict schema validation enforced, and dynamic execution paths avoided in Server Actions.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
React Server Components send data between browser and server in a packed form, and the server unpacks it. Here the unpacking trusted the incoming data so much that an attacker could make it build a runnable piece of code instead of plain data. That let them run their own commands on the server, which is called remote code execution.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.