The Great React2Shell Disaster: Your Server Got Pwned and You Did
React's Flight protocol for Server Components deserialised attacker-controlled payloads unsafely, letting a crafted request reach JavaScript's constructor chain. An unauthenticated attacker could then run arbitrary code on the server.
Published on medium.com
Remember when you thought your React app with that sweet Server-Side Rendering was secure? Yeah, about that…
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 Flight deserialiser followed attacker-supplied references such as constructor and __proto__ and trusted a spoofed hasOwnProperty check, so untrusted data reached code execution.
Impact
Attackers could gain interactive shell access, harvest environment variables and cloud credentials, reach metadata endpoints, install web shells and malware, and mine cryptocurrency; the text notes the exploit is unauthenticated but very noticeable in logs.
What the attacker needed
Network access to the app; no authentication needed; vulnerable React or Next.js version
The fix
Patched React and Next.js versions were released and should be applied, alongside secret rotation, log review and network segmentation.
How it was found
- Send a crafted HTTP request carrying a malicious Flight payload to the Next.js app.
- The server processes the payload without properly validating its structure.
- A fake hasOwnProperty method bypasses the security checks.
- The payload reaches the constructor property and then the Function constructor.
- Arbitrary JavaScript runs, including Node.js modules, giving shell commands on the server.
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 format called Flight. The server trusted that data too much, so a stranger could send a specially shaped message that made the server run their own commands. That means full control of the machine, with no login needed.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.