Skip to content
RCE Write-up Advanced

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.

CyferNest Sec Follow

Published on medium.com

Remember when you thought your React app with that sweet Server-Side Rendering was secure? Yeah, about that…

CyferNest Sec, on medium.com

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

  1. Send a crafted HTTP request carrying a malicious Flight payload to the Next.js app.
  2. The server processes the payload without properly validating its structure.
  3. A fake hasOwnProperty method bypasses the security checks.
  4. The payload reaches the constructor property and then the Function constructor.
  5. 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.

More by CyferNest Sec

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.