Issue 2342: Admin Route Guard Relies Solely on Route Handler
Summary
Admin routes (/admin/*) have no middleware-level guard. Protection relies entirely on requireAdminSession() in each route handler. If any future admin route forgets to call this function, it's immediately exploitable without authentication.
Affected Component
middleware.ts - Admin route handling
Vulnerability Details
The middleware explicitly skips authentication for admin routes:
if (isAdminRoute) {
const response = NextResponse.next();
addSecurityHeaders(response);
return response;
}
This creates a defense-in-depth gap:
- If a developer adds a new admin route and forgets
requireAdminSession(), it's immediately open
- There's no safety net at the middleware level
- Unlike other protected routes, there's no IP blocklist or rate limit specific to admin
The code comments acknowledge this limitation:
// We still attach the security headers + skip /admin/login from any host-
// level redirects above.
Impact
Low - Current routes are protected, but the architecture invites future mistakes. A single forgotten auth check on a new admin endpoint could expose sensitive operations like price manipulation or market pausing.
Recommended Fix
Add a middleware-level guard for admin routes:
if (isAdminRoute) {
// Verify Privy session exists (not full validation, just presence check)
const auth = req.headers.get("authorization");
if (!auth?.startsWith("Bearer ")) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const response = NextResponse.next();
addSecurityHeaders(response);
return response;
}
Environment
- Production: percolatorlaunch.com
- All
/admin/* and /api/admin/* routes
Issue 2342: Admin Route Guard Relies Solely on Route Handler
Summary
Admin routes (
/admin/*) have no middleware-level guard. Protection relies entirely onrequireAdminSession()in each route handler. If any future admin route forgets to call this function, it's immediately exploitable without authentication.Affected Component
middleware.ts- Admin route handlingVulnerability Details
The middleware explicitly skips authentication for admin routes:
This creates a defense-in-depth gap:
requireAdminSession(), it's immediately openThe code comments acknowledge this limitation:
Impact
Low - Current routes are protected, but the architecture invites future mistakes. A single forgotten auth check on a new admin endpoint could expose sensitive operations like price manipulation or market pausing.
Recommended Fix
Add a middleware-level guard for admin routes:
Environment
/admin/*and/api/admin/*routes