Align tunnel request matching in middleware with tunnel rewrite
fix(v9/nextjs): Align tunnel request matching in middleware with tunnel rewrite (#24760)
Align tunnel request matching in middleware with tunnel rewritec122aa-fix-align-tunnel-request-matching-in-middleware-cve-2026-114139fixalign tunnel request matching middleware rewrite
Committed by chargome
commit message
fix(v9/nextjs): Align tunnel request matching in middleware with tunnel rewrite (#24760)
Backport of: #24499
## Differences to the original PR
- `packages/nextjs/src/common/utils/tunnelPathnameMatch.ts`: this file
doesn't exist on v9, so it's added here with only
`isSentryTunnelRequest`. `isPathnameUnderSentryTunnelRoute` is left out
because nothing on v9 uses it.
- On v9 the middleware checked tunnel requests with a plain
`pathname.startsWith(tunnelRoute)`, so a path like `/api/things` counted
as a tunnel request for `/api/t`. `develop` fixed that in an earlier PR.
The new exact matching fixes it on v9 too, so the test for that case
from `develop` is included here.Editor assessment
This commit patches CVE-2026-114139. A strong backport message. The body lists the differences from the original PR: the new tunnelPathnameMatch.ts with only isSentryTunnelRequest, the v9 startsWith bug that counted /api/things as a tunnel for /api/t, and the inclusion of the develop test. The v9/nextjs scope identifies the package line, which is acceptable in this monorepo. Clear and self-sufficient. Formally the body is well organized with differences and test notes; the version/package scope is acceptable in this monorepo and the message is self-sufficient.