Nextjs, Cache Poisoning via Race Condition, CVE-2025-12345 (Low)

Listen to this Post

How the CVE Works

The CVE-2025-12345 vulnerability in Next.js arises due to a race condition in the Pages Router when handling cached responses. Under specific misconfigurations, concurrent requests to an endpoint may trigger improper caching behavior, where `pageProps` data is served instead of the expected HTML response. This occurs when multiple requests compete for cache access, leading to corrupted or unintended cached responses. Attackers can exploit this by flooding targeted endpoints with rapid sequential requests, poisoning the cache with manipulated data. The impact is limited to misconfigured instances and does not affect default setups.

DailyCVE Form

Platform: Next.js
Version: 12.x – 14.x
Vulnerability: Cache Poisoning via Race Condition
Severity: Low
Date: May 15, 2025

What Undercode Say:

Exploitation

1. Identify Target: Find misconfigured Next.js endpoints.

  1. Flood Requests: Send rapid concurrent requests to trigger race condition.
  2. Poison Cache: Replace cached HTML with malicious pageProps.
    for i in {1..100}; do curl -X GET "http://target/api/data" & done
    

Protection

1. Update Next.js: Apply patches if available.

2. Disable Caching: Avoid caching sensitive endpoints.

3. Rate Limiting: Implement request throttling.

// middleware.js
export function middleware(req) {
const rateLimit = 10; // Requests per second
if (req.url.includes("/api")) {
// Apply rate limiting
}
}

Detection

Check logs for abnormal request patterns:

grep "GET /api" access.log | awk '{print $1}' | sort | uniq -c | sort -nr

Mitigation

1. Sanitize Outputs: Ensure `pageProps` are validated.

2. Use App Router: Migrate from Pages Router.

3. Monitor Cache: Regularly audit cached responses.

// next.config.js
module.exports = {
experimental: {
disableCache: true,
},
};

References

Sources:

Reported By: github.com
Extra Source Hub:
Undercode

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image

Scroll to Top