The vulnerability, GHSA-h27x-g6w4-24gq, describes an unbounded request body buffering issue in Next.js's Partial Prerendering (PPR) feature, leading to a potential Denial of Service. The analysis of the fixing commit, c885d4825f800dd1e49ead37274dcd08cdd6f3f1, pinpoints the exact location of the flaw.
The patch modifies two main files, packages/next/src/build/templates/app-page.ts and packages/next/src/server/base-server.ts, and introduces a new utility file packages/next/src/server/lib/postponed-request-body.ts containing the fix logic in the readBodyWithSizeLimit function.
The advisory mentions that a previous mitigation was incomplete and only protected 'minimal-mode' deployments. The code changes confirm this. The logic in base-server.ts already contained a size check, which was refactored to use the new centralized function. However, the code in packages/next/src/build/templates/app-page.ts within the exported handler function was missing this check entirely.
Specifically, the handler function in app-page.ts contained a for await...of loop that read all chunks from the request stream (req) and buffered them in an array before concatenating them. This is the vulnerable code path, as it doesn't validate the size of the incoming data. An attacker could exploit this by sending a POST request with the next-resume: 1 header and a multi-gigabyte body, causing the server's memory usage to spike, leading to a crash.
Therefore, the handler function is the primary vulnerable function. During exploitation, a runtime profiler would show this function being executed as it processes the malicious request that causes the memory exhaustion.