The vulnerability is a middleware authorization bypass in the @sentry/nextjs webpack integration. The root cause is a mismatch between two pieces of logic: (1) the tunnel rewrite (setUpTunnelRewriteRules) only serves the exact tunnel path with valid o (org) and p (project) query parameters, but (2) the middleware wrapper (wrapMiddlewareWithSentry) skipped the user's middleware for every request path under the configured tunnelRoute.
In the vulnerable code, wrapMiddlewareWithSentry checked isPathnameUnderSentryTunnelRoute(url.pathname, tunnelRoute) (which returned true for pathname === tunnelPath or any pathname.startsWith(tunnelPath + '/')), and on v9 it used an even looser url.pathname.startsWith(tunnelRoute). When this matched, it returned a synthetic Response with the x-middleware-next: 1 header, which tells Next.js to skip the user's middleware and continue to the route handler. Because this matching was broader than the actual tunnel rewrite, an unauthenticated request to a route that collides with the tunnel path (or a root dynamic segment resolving under it) would reach the application route without any middleware authorization.
The fix (commits 878b685, c122aac, d525a2f, and their PR equivalents) introduces a new isSentryTunnelRequest function that only returns true for POST requests to the exact tunnel path (with optional trailing slash) carrying numeric o and p query parameters, aligning the middleware-skip decision with what the tunnel rewrite actually serves.
The two vulnerable functions are:
wrapMiddlewareWithSentry — the wrapper that performed the overly-broad tunnel-route check and bypassed middleware.
isPathnameUnderSentryTunnelRoute — the helper whose startsWith-based matching was too broad and was the direct predicate for the bypass.
Both functions exist in the vulnerable versions (the patch modifies them rather than adding them), and both would appear in a runtime profile/stack trace during exploitation of this vulnerability.