The vulnerability is a cache poisoning issue in Next.js that leads to a Denial of Service. The root cause is the improper handling of HTTP 204 No Content responses for React Server Component (RSC) prefetch requests.
The analysis of the provided patches reveals two main areas of concern:
-
Client-Side Cache Handling: The functions fetchRouteOnCacheMiss and fetchSegmentEntryOnCacheMiss in packages/next/src/client/components/segment-cache/cache.ts were not treating 204 responses as cache misses. This meant that if the server responded with a 204, the client-side cache could store this as a valid response for a page or segment, effectively making it inaccessible.
-
Server-Side Response Generation: The request handling logic within the Server class in packages/next/src/server/base-server.ts was not consistently returning a 204 status code for prefetch requests that resulted in a cache miss. This inconsistent behavior is what triggered the client-side issue. The patch ensures that for RSC prefetch requests that miss the cache, the server reliably returns a 204 status code.
By fixing both the client-side handling and the server-side response, the patches prevent the cache poisoning from occurring. The vulnerable functions are those that were involved in this faulty request-response cycle for prefetched content.