/

CVE-2026-41248

Severity:

CRITICAL RISK

(9.1)

Route Matching and Authorization Bypass in Clerk Framework

CVE-2026-41248

Deferred

Vulnerability type

Category:

Route Matching and Authorization Bypass

CWE:

CWE-436, CWE-863

Impact:

Authentication and Authorization Bypass

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A route matching flaw in Clerk's createRouteMatcher utility for Next.js, Nuxt, and Astro allows specially crafted requests to bypass middleware-based authentication and authorization checks.

When triggered, the mismatch between intended and actual route handling can let unauthenticated or improperly authorized traffic reach downstream application handlers that were assumed to be protected.

Affected context

This vulnerability appears in applications that integrate Clerk authentication using the @clerk/nextjs, @clerk/nuxt, or @clerk/astro packages and depend on createRouteMatcher to gate routes via middleware.

It is relevant in scenarios where developers assume that only authenticated or authorized requests can reach specific handlers, but where crafted paths, encodings, or request shapes can evade the matcher logic.

The risk is highest when sensitive operations (account access, administrative actions, protected APIs) rely solely on this middleware gating without additional in-handler authorization checks.

Exploit preconditions

  • Attack surface: Public HTTP(S) endpoints of a web application using Clerk middleware routing helpers.
  • Required access: Network access to the affected routes; no valid user credentials are strictly required if the application trusts middleware for protection.
  • Trigger point: Dispatching specially structured requests (e.g., crafted paths, patterns, or encodings) that cause createRouteMatcher to misclassify a protected route as unprotected.
  • Why exploitation is possible: The route matching logic in createRouteMatcher does not fully align with the actual routing behavior of the framework, leading to cases where middleware gating is skipped even though the downstream handler is reachable and expects prior authentication.

Why this happens

The underlying problem is a logical inconsistency between how createRouteMatcher interprets and evaluates routes and how the web framework ultimately routes requests.

This falls under CWE-436: Interpretation Conflict, where two components (the router and the middleware matcher) interpret the same input differently.

As a result, certain request patterns can satisfy the framework's routing rules but not the matcher's patterns, causing the middleware not to execute.

Combined with reliance on middleware for access control, this also reflects CWE-863: Incorrect Authorization, because authorization decisions are made under the false assumption that all relevant requests are gated.

Potential impact

  • Unauthenticated users could reach endpoints that developers intended to protect with Clerk middleware.
  • Attackers may be able to invoke sensitive operations (e.g., accessing user data, invoking privileged business logic) without proper authentication or authorization.
  • Security assumptions about "protected routes" can be invalidated, potentially exposing internal APIs, admin panels, or configuration endpoints.
  • Abuse of business workflows (e.g., account management, billing actions, or data export features) that rely solely on middleware gating for protection.

General mitigation guidance

Effective mitigation centers on ensuring that route protection does not depend on a single, potentially misaligned matcher:

  • Favor framework-native mechanisms for route protection where possible, aligning authentication/authorization checks directly with the router's view of paths.
  • Treat path patterns, wildcards, and dynamic segments consistently between middleware matchers and actual route definitions; avoid complex or ambiguous matching rules that are easy to interpret differently.
  • Implement defense in depth by performing explicit authorization checks inside sensitive handlers, not just in middleware, so that a skipped middleware invocation does not automatically grant access.
  • Normalize and validate request paths before applying routing or matching logic, reducing discrepancies caused by encodings, trailing slashes, or unconventional path manipulations.
  • Apply least-privilege principles in business logic design, restricting powerful operations and requiring strong, explicit authorization regardless of route matching helpers.

How teams detect issues like this

Detection efforts should focus on both code-level patterns and behavioral anomalies:

  • Static analysis / code review:
  • Identify uses of createRouteMatcher (or similar helpers) that are assumed to fully protect sensitive routes.
  • Look for mismatch between matcher patterns and actual route definitions, especially where dynamic segments, wildcards, or nested paths are used.
  • Flag any handlers that perform sensitive actions but rely solely on middleware-based checks without in-handler authorization.
  • Runtime and testing:
  • Implement security tests or fuzzing of route paths and encodings to see if unauthenticated requests can reach supposedly protected endpoints.
  • Review access logs for unexpected unauthenticated hits to routes that should be gated by Clerk middleware.
  • Automated tooling:
  • Integrate linters or SAST tools configured to detect high-risk authorization patterns (e.g., "middleware-only protection" on critical endpoints).
  • Use CI policies that require explicit authorization checks for handlers implementing administrative or data-sensitive operations.

Sources

SourceLink
github.comgithub.com/clerk/javascript/security/advisories/GHSA-vqx2-fgx2-5wq9

Frequently asked

questions

Yes. Any remote client that can send HTTP(S) requests to an affected application's endpoints can potentially exploit the issue, assuming they can craft requests that bypass the route matcher.

Not necessarily. The core risk is that unauthenticated or low-privilege users might reach handlers that developers believed were protected by Clerk middleware. Access requirements depend on how individual routes are implemented, but middleware-only protections are particularly exposed.

Align route protection with the framework's routing model and avoid relying solely on a helper's pattern matching. Ensure middleware gate patterns accurately mirror route definitions, and add explicit in-handler authorization checks for high-value or sensitive operations as a backstop.

Standardize on a clear authorization architecture: centralize access control logic, avoid duplicated or ad hoc route-matching schemes, and normalize request paths before authorization decisions. Incorporate security reviews for routing and middleware configurations, and use automated tests to verify that protected routes remain inaccessible without proper authentication and authorization.

Find out what's already
exploitable in your codebase.