Next.js App Security Overhaul: Patches CSRF, Open Redirect, and Admin Route Vulnerabilities
A comprehensive security remediation effort has been completed for a Next.js application, addressing multiple critical vulnerabilities that exposed the platform to potential attacks. The update patches five specific CVEs in the core Next.js framework, including a CSRF bypass, HTTP request smuggling, and denial-of-service vectors. More critically, a live open redirect vulnerability was fixed in the `/auth/callback` endpoint, which could have been exploited to redirect users to malicious external sites. Simultaneously, the `/admin/courses` route, which was inexplicably missing server-side authentication and role checks, has been moved into a protected route group, closing a direct path to unauthorized administrative access.
The fixes extend beyond the application layer to its dependency chain. A ReDoS (Regular Expression Denial of Service) vulnerability identified by SonarQube in a planner module was resolved. Rate limiting and input validation were implemented on a specific signup verification API endpoint to prevent brute-force attacks. Furthermore, the effort standardized the usage of Supabase keys within a proxy service and patched multiple transitive dependency vulnerabilities in packages like `flatted`, `picomatch`, and `vite` via an `npm audit fix`.
This sweep represents a significant hardening of the application's security posture. The implementation of security headers—including X-Frame-Options, HSTS, and a strict Permissions-Policy—provides an additional layer of defense. The test plan mandates a clean `npm audit` with zero vulnerabilities, successful builds, and verified redirection of unauthenticated users away from the now-protected admin panel, signaling a shift from reactive patching to a more enforced security baseline.