CVE-2025-29927

9.1 CRITICAL

📋 TL;DR

This CVE describes an authorization bypass vulnerability in Next.js middleware. Attackers can bypass authorization checks by sending requests with the x-middleware-subrequest header, potentially accessing protected resources. This affects Next.js applications using middleware for authorization in versions 1.11.4 through 12.3.4, 13.5.8 and earlier, 14.2.24 and earlier, and 15.2.2 and earlier.

💻 Affected Systems

Products:
  • Next.js
Versions: 1.11.4 through 12.3.4, 13.5.8 and earlier, 14.2.24 and earlier, 15.2.2 and earlier
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using Next.js middleware for authorization checks. Applications without middleware or with authorization implemented elsewhere are not vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete compromise of protected application functionality, unauthorized access to sensitive data, privilege escalation, and potential data exfiltration.

🟠

Likely Case

Unauthorized access to protected routes and resources that should require authentication, potentially exposing user data or administrative functions.

🟢

If Mitigated

Limited impact with proper network controls and header filtering, though some risk remains until patching.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires sending HTTP requests with the x-middleware-subrequest header, which is straightforward for attackers with network access to the application.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 12.3.5, 13.5.9, 14.2.25, 15.2.3

Vendor Advisory: https://github.com/vercel/next.js/security/advisories/GHSA-f82v-jwr5-mffw

Restart Required: Yes

Instructions:

1. Identify your Next.js version. 2. Update to a patched version using npm: npm update next@latest or yarn upgrade next@latest. 3. Restart your Next.js application. 4. Test authorization functionality.

🔧 Temporary Workarounds

Block x-middleware-subrequest header at network level

all

Configure web application firewall or reverse proxy to drop requests containing the x-middleware-subrequest header from external sources.

# Example nginx configuration:
location / {
    if ($http_x_middleware_subrequest) {
        return 403;
    }
    # ... rest of configuration
}

🧯 If You Can't Patch

  • Implement network-level filtering to block requests with x-middleware-subrequest header from untrusted sources.
  • Move authorization logic out of middleware to server-side API routes or other secure locations.

🔍 How to Verify

Check if Vulnerable:

Check package.json for Next.js version. If version is between 1.11.4 and 12.3.4, or 13.5.8 or earlier, or 14.2.24 or earlier, or 15.2.2 or earlier, and the application uses middleware for authorization, it is vulnerable.

Check Version:

npm list next | grep next or check package.json file

Verify Fix Applied:

After updating, verify the version is 12.3.5+, 13.5.9+, 14.2.25+, or 15.2.3+. Test authorization endpoints with x-middleware-subrequest header to ensure they are properly blocked.

📡 Detection & Monitoring

Log Indicators:

  • HTTP requests with x-middleware-subrequest header in access logs
  • Unauthorized access attempts to protected routes

Network Indicators:

  • Incoming HTTP requests containing x-middleware-subrequest header
  • Unusual access patterns to protected endpoints

SIEM Query:

http.headers:x-middleware-subrequest AND (http.status:200 OR http.status:302) AND NOT user_agent:"internal"

🔗 References

📤 Share & Export