
Urgent Security Alert: Critical Next.js Vulnerability Exposes Web Apps to Unauthorized Access (CVE-2025-29927)
2025-03-24
Author: Jia
A newly discovered critical vulnerability in the popular open-source Next.js framework (designated as CVE-2025-29927) poses a significant threat to web applications, allowing malicious actors to bypass authorization controls and potentially gain access to restricted sections, including admin panels.
Vercel, the cloud service provider behind Next.js, has been proactive in addressing this issue and has released crucial security updates. Users are urged to upgrade their frameworks immediately to safeguard their applications.
Understanding Next.js and the Vulnerability
Next.js is a powerful full-stack framework built on React, designed to streamline the development of web applications with features like server-side rendering, routing, and SEO enhancements. The framework employs its own middleware for request processing, route protection, and handling user authentication.
The vulnerability identified as CVE-2025-29927 allows attackers to exploit the middleware security checks by sending specially crafted requests containing an `x-middleware-subrequest` header. When this header is included, the middleware functions are completely bypassed, enabling unauthorized access to potentially sensitive areas of the application.
Security researchers Rachid Allam and Yasser Allam, who uncovered this flaw, explained, “The addition of the `x-middleware-subrequest` header acts as a universal key that overrides security rules, allowing requests to reach their destination without any middleware interference.”
After discreetly reporting this vulnerability to Vercel, immediate patches were deployed on March 14, 2025, followed by a series of fixed version releases across various Next.js branches in the days that followed.
Who is Affected?
Next.js is widely embraced by prominent enterprises, including Twitch, Spotify, Binance, Hulu, TikTok, and OpenAI, making this vulnerability particularly impactful. A report from RunZero CEO HD Moore highlighted that the Shodan search engine has detected over 300,000 services utilizing the `X-Powered-By: Next.js` header, indicating a broad potential exposure.
All versions of Next.js were found vulnerable to CVE-2025-29927. However, this issue has been resolved in the following patched versions: 15.2.3, 14.2.25, 13.5.9, and 12.3.5. Importantly, applications hosted on Vercel and Netlify, or those deployed as static exports, are not affected due to the nature of middleware execution.
Recommended Actions
To protect against potential exploitation, Next.js maintainers recommend upgrading to a secure version at the earliest. If immediate patching isn't possible, they advise implementing measures to block external requests that contain the `x-middleware-subrequest` header from reaching the application.
In light of this vulnerability, ProjectDiscovery has provided guidelines on effective mitigation strategies. Additionally, Cloudflare is offering a rule to block these harmful requests for its Web Application Firewall (WAF) clients, along with instructions for creating custom rules for others.
Final Thought
As web applications continue to thrive in a digital landscape, it is crucial for developers and organizations utilizing Next.js to remain vigilant and proactive in addressing vulnerabilities. The urgency to patch and secure systems should never be underestimated—act now to protect your web applications from the looming threat of unauthorized access!