Security Advisory

Security Advisory

Security Advisory

Critical Security Vulnerability in Next.js (CVE-2025-29927)

Critical Security Vulnerability in Next.js (CVE-2025-29927)

CVE-2025-29927 exposes a flaw where the x-middleware-subrequest header can be exploited to skip middleware checks, leading to unauthorized access in affected Next.js applications.

CVE-2025-29927 exposes a flaw where the x-middleware-subrequest header can be exploited to skip middleware checks, leading to unauthorized access in affected Next.js applications.

CVE-2025-29927 exposes a flaw where the x-middleware-subrequest header can be exploited to skip middleware checks, leading to unauthorized access in affected Next.js applications.

3 Min

3 Min

3 Min

March 22, 2025

March 22, 2025

March 22, 2025

On March 21, 2025, a critical security vulnerability identified as CVE-2025-29927 was disclosed, affecting Next.js, a popular React framework for building full-stack web applications. This vulnerability allows attackers to bypass authorization checks implemented in Next.js middleware, potentially granting unauthorized access to sensitive areas of applications.

Understanding the Vulnerability

Next.js middleware functions as an intermediary that processes requests before they reach the application's main logic. Developers often use middleware for tasks such as authentication, logging, and security enforcement. The vulnerability arises from improper handling of the x-middleware-subrequest HTTP header, which is internally used by Next.js to prevent infinite recursive loops in middleware execution.

By crafting requests that include the x-middleware-subrequest header with specific values, an attacker can trick Next.js into skipping middleware execution entirely. This means that any security checks, including authentication and authorization, performed within the middleware can be bypassed, leading to unauthorized access to protected resources. ​

Affected Versions

The vulnerability impacts the following versions of Next.js:​

  • 11.x: from 11.1.4 up to, but not including, 12.3.5​

  • 13.x: from 13.0.0 up to, but not including, 13.5.9​

  • 14.x: from 14.0.0 up to, but not including, 14.2.25​

  • 15.x: from 15.0.0 up to, but not including, 15.2.3​

Applications hosted on Vercel, Netlify, or deployed as static exports are not affected by this vulnerability. ​

Mitigation Steps

To address this vulnerability, it is recommended to upgrade Next.js to the latest patched versions:

  • For Next.js 15.x, update to version 15.2.3

  • For Next.js 14.x, update to version 14.2.25​

  • For Next.js 13.x, update to version 13.5.9​

  • For Next.js 12.x, update to version 12.3.5​

If immediate patching is not feasible, it is advisable to configure your web server or proxy to block or reject requests containing the x-middleware-subrequest header. ​

Conclusion

CVE-2025-29927 is a critical vulnerability that underscores the importance of robust security practices in web application development. Developers should promptly update their Next.js applications to the latest versions and ensure that authorization checks are not solely reliant on middleware. Implementing multiple layers of security can help mitigate the risk of similar vulnerabilities in the future.

On March 21, 2025, a critical security vulnerability identified as CVE-2025-29927 was disclosed, affecting Next.js, a popular React framework for building full-stack web applications. This vulnerability allows attackers to bypass authorization checks implemented in Next.js middleware, potentially granting unauthorized access to sensitive areas of applications.

Understanding the Vulnerability

Next.js middleware functions as an intermediary that processes requests before they reach the application's main logic. Developers often use middleware for tasks such as authentication, logging, and security enforcement. The vulnerability arises from improper handling of the x-middleware-subrequest HTTP header, which is internally used by Next.js to prevent infinite recursive loops in middleware execution.

By crafting requests that include the x-middleware-subrequest header with specific values, an attacker can trick Next.js into skipping middleware execution entirely. This means that any security checks, including authentication and authorization, performed within the middleware can be bypassed, leading to unauthorized access to protected resources. ​

Affected Versions

The vulnerability impacts the following versions of Next.js:​

  • 11.x: from 11.1.4 up to, but not including, 12.3.5​

  • 13.x: from 13.0.0 up to, but not including, 13.5.9​

  • 14.x: from 14.0.0 up to, but not including, 14.2.25​

  • 15.x: from 15.0.0 up to, but not including, 15.2.3​

Applications hosted on Vercel, Netlify, or deployed as static exports are not affected by this vulnerability. ​

Mitigation Steps

To address this vulnerability, it is recommended to upgrade Next.js to the latest patched versions:

  • For Next.js 15.x, update to version 15.2.3

  • For Next.js 14.x, update to version 14.2.25​

  • For Next.js 13.x, update to version 13.5.9​

  • For Next.js 12.x, update to version 12.3.5​

If immediate patching is not feasible, it is advisable to configure your web server or proxy to block or reject requests containing the x-middleware-subrequest header. ​

Conclusion

CVE-2025-29927 is a critical vulnerability that underscores the importance of robust security practices in web application development. Developers should promptly update their Next.js applications to the latest versions and ensure that authorization checks are not solely reliant on middleware. Implementing multiple layers of security can help mitigate the risk of similar vulnerabilities in the future.

On March 21, 2025, a critical security vulnerability identified as CVE-2025-29927 was disclosed, affecting Next.js, a popular React framework for building full-stack web applications. This vulnerability allows attackers to bypass authorization checks implemented in Next.js middleware, potentially granting unauthorized access to sensitive areas of applications.

Understanding the Vulnerability

Next.js middleware functions as an intermediary that processes requests before they reach the application's main logic. Developers often use middleware for tasks such as authentication, logging, and security enforcement. The vulnerability arises from improper handling of the x-middleware-subrequest HTTP header, which is internally used by Next.js to prevent infinite recursive loops in middleware execution.

By crafting requests that include the x-middleware-subrequest header with specific values, an attacker can trick Next.js into skipping middleware execution entirely. This means that any security checks, including authentication and authorization, performed within the middleware can be bypassed, leading to unauthorized access to protected resources. ​

Affected Versions

The vulnerability impacts the following versions of Next.js:​

  • 11.x: from 11.1.4 up to, but not including, 12.3.5​

  • 13.x: from 13.0.0 up to, but not including, 13.5.9​

  • 14.x: from 14.0.0 up to, but not including, 14.2.25​

  • 15.x: from 15.0.0 up to, but not including, 15.2.3​

Applications hosted on Vercel, Netlify, or deployed as static exports are not affected by this vulnerability. ​

Mitigation Steps

To address this vulnerability, it is recommended to upgrade Next.js to the latest patched versions:

  • For Next.js 15.x, update to version 15.2.3

  • For Next.js 14.x, update to version 14.2.25​

  • For Next.js 13.x, update to version 13.5.9​

  • For Next.js 12.x, update to version 12.3.5​

If immediate patching is not feasible, it is advisable to configure your web server or proxy to block or reject requests containing the x-middleware-subrequest header. ​

Conclusion

CVE-2025-29927 is a critical vulnerability that underscores the importance of robust security practices in web application development. Developers should promptly update their Next.js applications to the latest versions and ensure that authorization checks are not solely reliant on middleware. Implementing multiple layers of security can help mitigate the risk of similar vulnerabilities in the future.

Outsmart risk, every time.

Resources

Examples

Community

Guides

Docs

Legal

Privacy

Terms

Security