← Back to list

Next.js Middleware Authentication Bypass Through Client-Controlled Internal Header

In recent CTF challenge, authentication bypass was identified in a Next.js application. The issue arises from improper trust in a…

Cyb3rV0lt in MeetCyber · 2026-05-14 15:55 · 7 claps · 1.5 min read
#authentication-bypass #cybersecurity #ethical-hacking #ctf #bug-bounty
Open on Medium ↗
Wiki topics: 🌐 · Web Development 🔒 · Cybersecurity

Next.js Middleware Authentication Bypass Through Client-Controlled Internal Header

In recent CTF challenge, authentication bypass was identified in a Next.js application. The issue arises from improper trust in a client-controlled internal header used by the framework’s middleware layer.

By manipulating the x-middleware-subrequest header, it was possible to bypass authentication checks and directly access restricted endpoints such as /dashboard.

The target application is built using Next.js 14.x, which relies heavily on middleware for request filtering and authentication enforcement.

/dashboard → Requires authentication

Unauthenticated users are normally redirected to the login page.

In initial recon phase found the hidden path and sensitive information like internal header used for subrequest routing.

robots.txt

robots.txt

when accessing the /dashboard endpoint without authentication it is temporary redirect to /login page. At this stage, standard access control appeared properly implemented.

during recon we found the x-middleware-subrequest header is used for subrequest routing purpose.

By adding the x-middleware-subrequestheader, the middleware authentication layer was completely bypassed, and the protected dashboard page was returned successfully.

dashboard

dashboard

Root Cause Analysis: the application treated an internal Next.js control header as a trusted security signal.

Thanks for reading!

follow me for more cybersecurity content : Medium Blog

Subscribe My youtube channel : https://www.youtube.com/@cybervolt07

Your support helps me keep sharing more content. See you in the next one!


메타데이터
post_id
eaba7e755259
slug
next-js-middleware-authentication-bypass-through-client-controlled-internal-header-eaba7e755259
url
https://meetcyber.net/next-js-middleware-authentication-bypass-through-client-controlled-internal-header-eaba7e755259
canonical_url
https://meetcyber.net/next-js-middleware-authentication-bypass-through-client-controlled-internal-header-eaba7e755259
author_url
https://medium.com/@cybervolt07
status
ok
fetched_at
2026-06-09 15:37:30