Next.js Critical Middleware Vulnerability (CVE-2025-29927) Explained

by Ali Shan, Developer / Writer

The Next.js team has disclosed a severe security vulnerability affecting self-hosted Next.js applications using Middleware. Tracked as CVE-2025-29927, this exploit carries a CVSS severity of 9.1—posing a major risk to projects relying on Middleware for authorization and security checks.

Next.js Vulnerability

What Caused the Vulnerability?

Next.js uses an internal header x-middleware-subrequest to prevent recursive requests in Middleware. The vulnerability allowed attackers to skip Middleware execution entirely by crafting requests that bypassed this internal check.

The result?

  • Critical checks like authorization cookies were skipped
  • Attackers could directly access protected routes without authentication
  • Real risk of privilege escalation or data exposure

Who is Affected?

Impacted:

  • Self-hosted Next.js apps
  • Running next start with output: 'standalone'
  • Middleware-based authentication or security flows

Not Affected:

  • Apps hosted on Vercel or Netlify
  • Static exports (Middleware skipped)

Timeline of the Incident

DateEvent
2025-02-27Vulnerability disclosed privately to Next.js team via GitHub
2025-03-14Triage completed, patches created
2025-03-18Next.js 15.2.3 released with the patch
2025-03-18CVE-2025-29927 officially published by GitHub
2025-03-22 - 23Backported patches released for 14.x, 13.x, and 12.x

Patched Versions

Next.js VersionPatched Release
15.x15.2.3
14.x14.2.25
13.x13.5.9
12.x12.3.5

What Should You Do Now?

If you're self-hosting and rely on Middleware:

  • Upgrade immediately to the correct patched version
  • If patching isn't possible, block requests with the x-middleware-subrequest header
  • Cloudflare users: Enable WAF rules

Next.js Security Takeaways

CVE-2025-29927 shows how complex SSR and Middleware flows can introduce serious risks.

The Next.js team has issued 16 security advisories since 2016, but this one stands out due to:

  • Impact on core auth and security
  • Simple bypass with a header
  • Broad scope of affected versions

Final Thoughts

Modern frameworks are powerful but increase your attack surface. Always stay updated and monitor advisories like this one.

Top tip

Security isn't optional—keep your Next.js apps patched and audited regularly.

More articles

K2-THINK: A New Paradigm for Parameter-Efficient Reasoning

K2-THINK, developed by MBZUAI, challenges the notion that bigger is always better in AI. With just 32B parameters, it delivers frontier-level reasoning through innovative training and inference strategies, redefining efficiency and accessibility in large language models.

Read more

The RAG Imperative: Bridging the Gap Between Models and Reality

An in-depth exploration of Retrieval-Augmented Generation (RAG), its architecture, enterprise value, challenges, comparison with fine-tuning, and its future as a foundational AI framework.

Read more

Ready to start your project?

Our office

  • Pakistan
    Islamabad Pakistan
    Sector H-8
  • Pakistan
    Gilgit Pakistan
    Jutial Gilgit