Saturday, June 13, 2026

Security Boulevard Logo

Security Boulevard

The Home of the Security Bloggers Network

Community Chats Webinars Library
  • Home
    • Cybersecurity News
    • Features
    • Industry Spotlight
    • News Releases
  • Security Creators Network
    • Latest Posts
    • Syndicate Your Blog
    • Write for Security Boulevard
  • Webinars
    • Upcoming Webinars
    • Calendar View
    • On-Demand Webinars
  • Events
    • Upcoming Events
    • On-Demand Events
  • Sponsored Content
  • Chat
    • Security Boulevard Chat
    • Marketing InSecurity Podcast
    • Techstrong.tv Podcast
    • TechstrongTV - Twitch
  • Library
  • Related Sites
    • Techstrong Group
    • Cloud Native Now
    • DevOps.com
    • Security Boulevard
    • Techstrong Research
    • Techstrong TV
    • Techstrong.tv Podcast
    • Techstrong.tv - Twitch
    • Devops Chat
    • DevOps Dozen
    • DevOps TV
  • Media Kit
  • About
    • Sponsor

  • Analytics
  • AppSec
  • CISO
  • Cloud
  • DevOps
  • GRC
  • Identity
  • Incident Response
  • IoT / ICS
  • Threats / Breaches
  • More
    • Blockchain / Digital Currencies
    • Careers
    • Cyberlaw
    • Mobile
    • Social Engineering
  • Humor
Best of 2025 Editorial Calendar Featured Security Boulevard (Original) Social - Facebook Social - LinkedIn Social - X Spotlight 

Home » Editorial Calendar » Best of 2025 » Best of 2025: CVE-2025-29927 – Understanding the Next.js Middleware Vulnerability

Best of 2025: CVE-2025-29927 – Understanding the Next.js Middleware Vulnerability

by strobes on January 1, 2026

When security vulnerabilities appear in popular frameworks, they can affect thousands of websites overnight. That’s exactly what’s happening with a newly discovered vulnerability in Next.js – one of the most widely used React frameworks today.

Let’s break down this surprisingly simple but dangerous security flaw.

What Makes This Vulnerability So Dangerous?

Imagine building a house with a sophisticated security system, but accidentally installing a secret button that disables all the alarms at once. That’s essentially what happened with Next.js.

The vulnerability (officially called CVE-2025-29927) affects Next.js versions 11.1.4 through 15.2.2 – which means years worth of websites are potentially vulnerable.

Here’s the shocking part: all it takes to bypass security is adding a single HTTP header to your request:

x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware

Add this to any request, and suddenly all of Next.js’s security checks disappear. No login needed. No security barriers. Nothing.

Understanding Next.js Middleware

To understand why this works, we need to know a bit about middleware.

Next.js middleware acts like a security guard that checks visitors before they reach your actual website content. It runs before any page loads and can:

    • Check if users are logged in
    • Block visitors from certain countries
    • Add security headers to prevent attacks
    • Redirect users to different pages

About 15% of React applications use Next.js, and many rely on middleware for their core security.

How The Bug Actually Works

The problem stems from a mechanism designed to prevent infinite loops. Next.js needed a way to stop middleware from calling itself endlessly, so developers added a counter.

Here’s what happens:

    1. Every time middleware runs, Next.js checks a special header called
      x-middleware-subrequest
    2. This header contains a count of how many times middleware has run
    3. If it has run too many times (5 by default), Next.js skips the middleware entirely
    4. The critical flaw: anyone can set this header themselves

Looking at the actual code makes it clearer:

// From Next.js's source code (simplified)
const subrequests = request.headers.get('x-middleware-subrequest')?.split(':') || [];  
const depth = subrequests.filter(s => s === middlewareName).length;  

if (depth >= MAX_RECURSION_DEPTH) {  
  return NextResponse.next(); // Skip all middleware!
}

ThemiddlewareNameis usually something likemiddlewareorsrc/middlewaredepending on your project setup. By repeating this name in the header several times, an attacker tricks Next.js into thinking middleware has already run too many times.

Testing For This Vulnerability

Anyone can verify if their Next.js application is vulnerable using a special test application created for this purpose: https://github.com/strobes-security/nextjs-vulnerable-app

The testing process works like this:

    1. Clone the repository:git clone https://github.com/strobes-security/nextjs-vulnerable-app
    2. Install dependencies and start the app:npm install && npm run dev
    3. Try accessing the/dashboardpage – you’ll be redirected to login
    4. Now try with the special header:
curl -v -H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" \
http://localhost:3000/dashboard

Suddenly, the dashboard appears without any login. The security is completely bypassed.

Different Project Structures Need Different Exploits

The exact header value changes depending on how your Next.js project is set up:

    • Pages Router (versions 11.1.4-12.1.x):x-middleware-subrequest: pages/_middleware
    • App Router (versions 12.2.x-13.x):x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware
    • App Router with /src folder (versions 14.x-15.2.2):x-middleware-subrequest: src/middleware:src/middleware:src/middleware:src/middleware:src/middleware

Real-World Security Impacts

This vulnerability opens several serious attack paths:

    1. Complete Authentication Bypass Attackers can access admin panels, private dashboards, or user data without logging in.
    2. Content Security Policy Bypass Middleware often sets CSP headers that prevent cross-site scripting. With this bypass, those protections vanish: bashCopycurl -H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" \ -H "Content-Type: text/html" --data "<script>alert('hacked')</script>" \ http://example-site.com
    3. Geographic Restrictions Bypass Many sites use middleware to restrict content by location. This header bypasses those checks: bashCopycurl -H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" \ -H "CF-IPCountry: RU" http://example-site.com/eu-only-content

Protecting Your Next.js Applications

There are three main ways to fix this vulnerability:

    1. Update Next.js Immediately
        • Upgrade to version 15.2.3+ or 14.2.25+
        • These versions have patched the security hole
    2. Block The Dangerous Header If updating isn’t possible right away, block the header at the web server level: For NGINX: nginxCopylocation / { proxy_set_header x-middleware-subrequest ""; }For Apache: apacheCopyRequestHeader unset x-middleware-subrequest
    3. Implement Defense-in-Depth
        • Don’t rely solely on middleware for security
        • Add server-side authentication checks (like with NextAuth.js)
        • For critical paths, add redundant security layers

Key Security Lessons From This Vulnerability

This bug teaches three fundamental security principles:

    1. Security Needs Multiple Layers Like an onion or a castle with multiple walls, security should have fallback layers. If middleware fails, other security checks should still protect your application.
    2. Never Trust User-Controlled Input Any data from users – including HTTP headers – can be manipulated. Always validate or sanitize input.
    3. Simple Bugs Can Cause Major Problems This vulnerability wasn’t complex. It was a simple oversight in how a counter worked. Yet it compromised thousands of applications.

Checking Your Own Applications

If you run Next.js applications, take these steps immediately:

    1. Test your applications with the exploit payloads listed above
    2. Review all middleware configurations for security dependencies
    3. Update to the latest version as soon as possible

For more technical details, refer to:

    • The official CVE report: CVE-2025-29927
    • Additional technical analysis: Zhero Web Security Research
    • The vulnerable test app: GitHub Repository

Why Web Security Is Always Evolving

This vulnerability reminds us that security is never “done.” It’s an ongoing process. Even popular, well-maintained frameworks can have critical flaws discovered years after release.

The good news? The Next.js team responded quickly with patches. But this incident serves as a powerful reminder that we need to stay vigilant, keep our dependencies updated, and always implement multiple layers of security.

Have you checked your Next.js applications yet? The fix is simple, but only if you apply it.

The post CVE-2025-29927 – Understanding the Next.js Middleware Vulnerability appeared first on Strobes Security.

Recent Articles By Author
  • Scaling CTEM – From Proof of Concept to Enterprise Reality (Part 3)
  • External Network Penetration Testing Checklist for 2025
  • Penetration Testing Methodology: Step-by-Step Breakdown for 2025
More from strobes
January 1, 2026December 31, 2025 strobes CVE, CVE-2025-29927
  • ← Best of 2025: Google Gemini AI Flaw Could Lead to Gmail Compromise, Phishing
  • Is Cloud-Native Security getting better with new tech →

Techstrong TV

Click full-screen to enable volume control
Watch latest episodes and shows

Tech Field Day Events

Upcoming Webinars

Agentic Software Delivery in 2026: How To Bridge The Gap Between AI Ambition and Delivery Confidence
The Cost of Exposure: Managing the Operational Risks of Executive Security Incidents
Untangling the EU Cyber Resilience Act
The Software Supply Chain Just Got Harder to See
Building a Resilient Security Culture in the AI Era with AWS & Datadog

Podcast

Listen to all of our podcasts

Secure by Design

1 week ago | Jack Poller

Senator Sanders Wants to Own AI Companies — and Hand America’s Adversaries the Keys

2 weeks ago | Jack Poller

NIST’s Nine: The PQC Signature Race Moves to Round Three

3 weeks ago | Jack Poller

The Quantum Arms Race: Why Washington Just Wrote a $2 Billion Check to Nine Companies

4 weeks ago | Jack Poller

Beyond Moore’s Law: The Hyper-Acceleration of Autonomous AI Cyber Capabilities

1 month ago | Jack Poller

The Exception Economy: When Security Teams Stop Protecting and Start Negotiating

Press Releases

GoPlus's Latest Report Highlights How Blockchain Communities Are Leveraging Critical API Security Data To Mitigate Web3 Threats

GoPlus’s Latest Report Highlights How Blockchain Communities Are Leveraging Critical API Security Data To Mitigate Web3 Threats

C2A Security’s EVSec Risk Management and Automation Platform Gains Traction in Automotive Industry as Companies Seek to Efficiently Meet Regulatory Requirements

C2A Security’s EVSec Risk Management and Automation Platform Gains Traction in Automotive Industry as Companies Seek to Efficiently Meet Regulatory Requirements

Zama Raises $73M in Series A Lead by Multicoin Capital and Protocol Labs to Commercialize Fully Homomorphic Encryption

Zama Raises $73M in Series A Lead by Multicoin Capital and Protocol Labs to Commercialize Fully Homomorphic Encryption

RSM US Deploys Stellar Cyber Open XDR Platform to Secure Clients

RSM US Deploys Stellar Cyber Open XDR Platform to Secure Clients

ThreatHunter.ai Halts Hundreds of Attacks in the past 48 hours: Combating Ransomware and Nation-State Cyber Threats Head-On

ThreatHunter.ai Halts Hundreds of Attacks in the past 48 hours: Combating Ransomware and Nation-State Cyber Threats Head-On

Subscribe to our Newsletters

Most Read on the Boulevard

Google Patches 429 Chrome Vulnerabilities in Major Browser Update
Anthropic’s Mythos Can Serve Up N-Day Exploits in Minutes or Hours
Zscaler Launches Industry-First Zero Trust Security for Agentic AI
ShinyHunters Secret to Success: Breaking the Trust Barrier
Keyfactor Adds Control Plane to Manage Machine Identities
Microsoft’s June 2026 Patch Tuesday Addresses 198 CVEs ( CVE-2026-49160, CVE-2026-50507)
ServiceNow Breach Explained: API Exposure, Risks & Security
Atomic Arch npm Campaign Adds Malicious Dependency
What Causes AI Data Leakage and Tips for Staying Protected
ServiceNow Discloses Security Incident Exposing Customer Data

Industry Spotlight

Anthropic Mythos AI Model Strikes Fear in Trump Administration, U.S. Banks
Cloud Security Cybersecurity Data Privacy Data Security Featured Incident Response Industry Spotlight Malware Mobile Security Network Security News Security Awareness Security Boulevard (Original) Social - Facebook Social - LinkedIn Social - X Spotlight Threats & Breaches Vulnerabilities 

Anthropic Mythos AI Model Strikes Fear in Trump Administration, U.S. Banks

April 12, 2026 Jeffrey Burt | Apr 12 Comments Off on Anthropic Mythos AI Model Strikes Fear in Trump Administration, U.S. Banks
The Day the Security Music Died
AI and Machine Learning in Security Cybersecurity Featured Industry Spotlight Security Boulevard (Original) Social - Facebook Social - LinkedIn Social - X Spotlight 

The Day the Security Music Died

April 8, 2026 Alan Shimel | Apr 08 Comments Off on The Day the Security Music Died
The Lock, Not the Alarm: How Palo Alto’s Koi Acquisition Rewrites Endpoint Security
Featured Industry Spotlight Security Boulevard (Original) Social - Facebook Social - LinkedIn Social - X Spotlight Uncategorized 

The Lock, Not the Alarm: How Palo Alto’s Koi Acquisition Rewrites Endpoint Security

February 18, 2026 Jack Poller | Feb 18 Comments Off on The Lock, Not the Alarm: How Palo Alto’s Koi Acquisition Rewrites Endpoint Security

Top Stories

ServiceNow Fixes Flaw That Could Lead to Unauthorized Access to Instances
Cloud Security Cybersecurity Data Privacy Data Security Featured Identity & Access Incident Response Mobile Security Network Security News Security Awareness Security Boulevard (Original) Social - Facebook Social - LinkedIn Social - X Spotlight Vulnerabilities 

ServiceNow Fixes Flaw That Could Lead to Unauthorized Access to Instances

June 11, 2026 Jeffrey Burt | 2 days ago 0
Zscaler Launches Industry-First Zero Trust Security for Agentic AI
AI and ML in Security Cybersecurity Featured News Security Boulevard (Original) Social - Facebook Social - LinkedIn Social - X Spotlight Zero-Trust 

Zscaler Launches Industry-First Zero Trust Security for Agentic AI

June 10, 2026 Jon Swartz | 2 days ago 0
Anthropic’s Mythos Can Serve Up N-Day Exploits in Minutes or Hours
Cloud Security Cybersecurity Data Privacy Data Security Featured Incident Response Malware Mobile Security Network Security News Security Awareness Security Boulevard (Original) Social - Facebook Social - LinkedIn Social - X Spotlight Threat Intelligence Vulnerabilities 

Anthropic’s Mythos Can Serve Up N-Day Exploits in Minutes or Hours

June 9, 2026 Jeffrey Burt | 3 days ago 0

Security Humor

Randall Munroe’s XKCD 'Soniferous Aether'

Randall Munroe’s XKCD ‘Soniferous Aether’

Download Free eBook

[su_panel border="0px solid #ddd" radius="0" text_align="center" padding-top="0px" padding-bottom="0px"]
Managing the AppSec Toolstack
[/su_panel]

Security Boulevard Logo White

DMCA

Join the Community

  • Add your blog to Security Creators Network
  • Write for Security Boulevard
  • Bloggers Meetup and Awards
  • Ask a Question
  • Email: [email protected]

Useful Links

  • About
  • Media Kit
  • Sponsor Info
  • Copyright
  • TOS
  • DMCA Compliance Statement
  • Privacy Policy

Related Sites

  • Techstrong Group
  • Cloud Native Now
  • DevOps.com
  • Digital CxO
  • Techstrong Research
  • Techstrong TV
  • Techstrong.tv Podcast
  • DevOps Chat
  • DevOps Dozen
  • DevOps TV
Powered by Techstrong Group
Copyright © 2026 Techstrong Group Inc. All rights reserved.
×

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.