Executive brief
Clerk's JavaScript authentication libraries for Next.js, Nuxt, and Astro contain a flaw in their createRouteMatcher function that allows attackers to craft malicious requests to bypass middleware-level route protection and access protected endpoints without authentication. While sessions remain secure and no existing users can be impersonated, this enables unauthorized access to protected API routes and server components that rely solely on middleware gating. Organizations using these SDKs should upgrade immediately to patched versions to prevent unauthorized access to protected features and data.
Technical details
The vulnerability exists in the createRouteMatcher function across @clerk/nextjs, @clerk/nuxt, and @clerk/astro SDKs, which can be bypassed via specially crafted HTTP requests that don't match expected patterns. The root cause lies in the route-matching logic used by clerkMiddleware to determine whether to enforce authentication. An unauthenticated attacker on the network can send malicious requests that circumvent the middleware's route-matching decision and reach downstream handlers (API routes, server components, server actions) without triggering the auth.protect() call. Critically, this bypass only affects the middleware-level gate decision; the underlying authentication state remains accurate, and auth() calls within route handlers continue to work correctly. The vulnerability can be exploited if an application relies exclusively on middleware-level route gating without additional server-side auth checks. Patches are available across all affected versions (e.g., @clerk/nextjs 5.7.6+, 6.39.2+, 7.2.1+) and are drop-in replacements with no API changes.
Affected products
- Clerk @clerk/nextjs 5.0.0 to 6.39.1, 7.0.0 to 7.2.0
- Clerk @clerk/nuxt 1.1.0 to 1.13.27, 2.0.0 to 2.2.1
- Clerk @clerk/astro 0.0.1 to 2.17.9, 3.0.0 to 3.0.14
- Clerk @clerk/shared 2.20.17 to 3.47.3, 4.0.0 to 4.8.0
Timeline
- 2026-04-15: disclosed: Publicly disclosed
- 2026-04-15: patched: Patches released for all affected versions