Skip to main content
Vulnerability Database/CVE-2025-49005

CVE-2025-49005: Next.js Cache Poisoning Vulnerability

CVE-2025-49005 is a cache poisoning flaw in Next.js App Router that causes HTML requests to return RSC payloads under certain conditions. This article covers the technical details, affected versions, impact, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2025-49005 Overview

CVE-2025-49005 is a cache poisoning vulnerability affecting Next.js App Router versions 15.3.0 through 15.3.2 and Vercel CLI versions 41.4.1 through 42.2.0. Under certain conditions, page requests for HTML content could return a React Server Component (RSC) payload instead. On Vercel-hosted deployments, impact is limited to the browser cache. Self-hosted deployments behind a Content Delivery Network (CDN) that does not distinguish between RSC and HTML in cache keys can experience shared cache poisoning. The issue is tracked under [CWE-444] (Inconsistent Interpretation of HTTP Requests) and was resolved in Next.js 15.3.3.

Critical Impact

Self-hosted Next.js deployments behind CDNs lacking RSC/HTML cache key separation can serve corrupted content to all users of a cached route.

Affected Products

  • Vercel Next.js versions 15.3.0 through 15.3.2 (App Router)
  • Vercel CLI versions 41.4.1 through 42.2.0
  • Self-hosted Next.js deployments behind third-party CDNs

Discovery Timeline

  • 2025-07-03 - CVE-2025-49005 published to the National Vulnerability Database (NVD)
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-49005

Vulnerability Analysis

The vulnerability arises from how the Next.js App Router handles response headers for routes that can produce both HTML documents and RSC payloads. A regression in version 15.3.0 skipped setting the Vary header for basic routes. Without Vary: RSC (or an equivalent), intermediaries treat an HTML request and an RSC request as identical cache entries. An attacker who triggers an RSC response for a route can poison the shared cache so subsequent HTML requests receive the RSC payload. Users of the affected route then receive a broken or unexpected response.

Root Cause

The root cause is a missing Vary header on basic routes introduced by the commit titled "[next-server] skip setting vary header for basic routes." Next.js uses request headers such as RSC, Next-Router-State-Tree, and Next-Router-Prefetch to differentiate response types. When the server omits Vary for these headers, downstream caches collapse the variants into a single cache key.

Attack Vector

The attack requires network access to the application and the presence of a shared CDN or proxy cache. The attacker issues an RSC-style request with headers like RSC: 1 to a route that normally returns HTML. The cache stores the RSC payload under a key that will also match normal HTML requests. Later visitors receive the poisoned payload until the entry expires.

typescript
// Patch excerpt: packages/next/src/server/base-server.ts
// Reverts "[next-server] skip setting vary header for basic routes"
import {
  NEXT_ROUTER_SEGMENT_PREFETCH_HEADER,
  NEXT_DID_POSTPONE_HEADER,
  NEXT_URL,
  NEXT_ROUTER_STATE_TREE_HEADER,
  NEXT_IS_PRERENDER_HEADER,
} from '../client/components/app-router-headers'
// Source: https://github.com/vercel/next.js/commit/ec202eccf05820b60c6126d6411fe16766ecc066

Detection Methods for CVE-2025-49005

Indicators of Compromise

  • Cached responses on text/html routes containing RSC payload markers such as serialized Flight data beginning with numeric chunk prefixes.
  • Repeated client-side hydration failures or blank pages for users hitting cached routes.
  • CDN logs showing cache HITs for a route with mixed Content-Type or missing Vary: RSC response header.

Detection Strategies

  • Inspect production response headers for Next.js routes and confirm Vary includes RSC, Next-Router-State-Tree, Next-Router-Prefetch, and Next-Url.
  • Issue synthetic requests with and without the RSC: 1 header and compare cache keys and bodies returned by the CDN.
  • Review browser error telemetry and real-user monitoring for sudden spikes in client hydration or routing errors tied to cached pages.

Monitoring Recommendations

  • Alert on CDN edge logs that record HTML cache entries served with RSC Content-Type or Flight payload signatures.
  • Track deployment inventory for Next.js versions in the 15.3.0 to 15.3.2 range and Vercel CLI 41.4.1 to 42.2.0.
  • Monitor the GitHub Security Advisory GHSA-r2fc-ccr8-96c4 for any supplemental guidance.

How to Mitigate CVE-2025-49005

Immediate Actions Required

  • Upgrade Next.js to version 15.3.3 or later as documented in the GitHub Release v15.3.3.
  • Upgrade Vercel CLI to a version newer than 42.2.0.
  • Purge CDN caches after upgrading to evict any poisoned entries created before patching.

Patch Information

The fix restores the Vary header behavior in packages/next/src/server/base-server.ts and is included in Next.js 15.3.3. See the GitHub Commit Reference and the Vercel Changelog CVE-2025-49005 for full details.

Workarounds

  • Configure the CDN to include the RSC request header in the cache key for all Next.js routes.
  • Add Vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url at the edge for responses from affected applications.
  • Disable shared caching for App Router pages until the upgrade completes.
bash
# Example: CloudFront cache policy additions for Next.js App Router
# Include RSC-related headers in the cache key
aws cloudfront create-cache-policy \
  --cache-policy-config '{
    "Name": "NextJS-RSC-Aware",
    "DefaultTTL": 60,
    "ParametersInCacheKeyAndForwardedToOrigin": {
      "HeadersConfig": {
        "HeaderBehavior": "whitelist",
        "Headers": {
          "Quantity": 4,
          "Items": ["RSC", "Next-Router-State-Tree", "Next-Router-Prefetch", "Next-Url"]
        }
      },
      "CookiesConfig": {"CookieBehavior": "none"},
      "QueryStringsConfig": {"QueryStringBehavior": "all"},
      "EnableAcceptEncodingGzip": true
    }
  }'

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.