Why React/Vue/Next route guards don't enforce access control, how bundles leak admin routes, CVE-2025-29927, and the server-side checks that stop BOLA.
01Methodology
Standards and advisory review (CWE-602/639/285, OWASP ASVS 5.0 V8, OWASP API Top 10 2023 API1/API5, Next.js GHSA-f82v-jwr5-mffw / CVE-2025-29927), plus a local SPA+API lab and a GHSA version checker. Qualitative; no prevalence claim.
02Findings
Client route guards are presentation. Without server-side function- and object-level checks, a low-privilege session reaches admin APIs and other users' objects. CVE-2025-29927 showed the same failure one layer deeper when middleware was the sole check.
03Impact
UI-only authz enables BFLA and BOLA and accelerates privileged-feature discovery via bundle route tables. Middleware-only authz was bypassable on affected self-hosted Next.js versions until patched.
04Mitigation
Enforce ASVS 8.2.1 / 8.2.2 / 8.3.1 at a trusted service layer; patch Next.js to a fixed release or filter x-middleware-subrequest; keep Proxy/middleware optimistic only.
05Full analysis
A route guard decides which screen the browser draws. It does not decide who can read the data behind that screen. It is easy to mistake the first for the second, so this note lays out why the gap exists, what a real framework bug taught everyone about it in 2025, and what the server has to do instead. It closes with a small lab I ran to show the difference end to end.
Scope: single-page apps (SPAs) and meta-frameworks that render or route in the browser, backed by an HTTP or GraphQL API. Method: standards and advisory review (CWE, OWASP ASVS 5.0, OWASP API Security Top 10 2023, the Next.js advisory for CVE-2025-29927), plus a local lab. No prevalence claims: this is a pattern study, not a survey.
The pattern
Most SPAs follow the same flow:
The user opens /app/admin/users.
The server or CDN returns the same app shell and JavaScript bundle it returns for every path.
The client router matches the path and runs a guard: if the user's role is not admin, redirect to /403.
If the guard passes, the admin screen mounts and calls /api/admin/users.
Step 3 feels like access control. It is presentation. The guard runs in a browser the user controls, and the data lives behind step 4. Anyone can skip the router and send step 4 themselves, with curl, a proxy or the browser console.
MITRE has a name for this design: CWE-602, Client-Side Enforcement of Server-Side Security, where "the product is composed of a server that relies on the client to implement a mechanism that is intended to protect the server." Its mitigation is just as plain: any security check done on the client must be duplicated on the server.
Where it breaks
Function level. The admin screen is hidden, but the admin API answers anyone with a valid session. That is API5:2023 Broken Function Level Authorization. OWASP's prevention advice is that enforcement "should deny all access by default, requiring explicit grants to specific roles for access to every function."
Route inventory. Bundles ship the full route table, including screens a user will never see. A route name is not a secret and should not need to be, but it tells a tester exactly which APIs to try. The lab below pulls the admin paths out of the bundle with one grep.
Optimistic checks treated as final. A cookie being present says someone logged in once. It does not say this user may touch this record. Treating "has a session cookie" as "is authorized" is where client-side thinking leaks onto the server.
The real-world case: CVE-2025-29927
In March 2025, Next.js disclosed CVE-2025-29927, titled in the GitHub advisory GHSA-f82v-jwr5-mffw as "Authorization Bypass in Next.js Middleware." Its impact statement is one sentence: "It is possible to bypass authorization checks within a Next.js application, if the authorization check occurs in middleware."
What happened, at the level the vendor published it:
Next.js used an internal header, x-middleware-subrequest, to stop middleware from calling itself recursively. Per the Next.js postmortem, the header signalled that middleware had already run. The fix added validation of that header and filtered it out when validation failed.
Affected: self-hosted apps using next start or output: 'standalone', from 11.1.4 (NVD's affected range) up to the fixed releases. Fixed in: 12.3.5, 13.5.9, 14.2.25 and 15.2.3 (GHSA). 11.x has no patched release; the advisory points 11.x users to the workaround. Static exports were not affected (no middleware without a server runtime), and the postmortem says apps hosted on Vercel, Netlify and Cloudflare Workers were not affected because routing runs separately there.
Timeline (postmortem): reported 27 Feb 2025, patched for 14.x and 15.x on 17–18 Mar, made public 21 Mar, backported to 13.5.9 on 22 Mar and 12.3.5 on 23 Mar.
Why it belongs in a note about SPA guards: the postmortem itself says some apps use middleware "to optimistically verify a user's authentication state by checking cookies," and that Vercel does "not recommend Middleware to be the sole method of protecting routes." The advisory scopes the impact to authorization checks that occur in middleware, so an app that also checked authorization next to the data still had that second check when middleware was skipped. Same lesson as the client-side guard, one layer further in: a check at the routing edge is a filter, not the boundary.
The framework has since leaned into that. In Next.js 16 the middleware file convention is deprecated and renamed to proxy, and the Proxy docs now say to "always verify authentication and authorization inside each Server Function rather than relying on Proxy alone." The authentication guide recommends a Data Access Layer to centralize authorization, with Proxy used only for optional optimistic checks.
Detection and patching
Find your versions. Check every lockfile, not just package.json. The lab includes a small checker built from the GHSA ranges.
Patch. Move to a fixed release on your line, or to a current supported major.
If you cannot patch yet, follow the advisory's workaround: stop external requests that carry x-middleware-subrequest from reaching the app, at your reverse proxy, load balancer or WAF.
Detect. Log and alert on inbound requests carrying that header at the edge. Normal clients have no reason to send it.
Fix the design. Even on a patched version, add an authorization check next to each data read and mutation, so the next routing-layer bug is not a data breach.
8.2.1: function-level access is restricted to consumers with explicit permissions.
8.2.2: data-specific access is restricted to consumers with explicit permissions to specific data items, to mitigate IDOR and BOLA.
8.3.1: authorization rules are enforced at a trusted service layer, and the app "doesn't rely on controls that an untrusted consumer could manipulate, such as client-side JavaScript."
8.3.1 is this whole note in one line.
Lab: a client-side guard, bypassed and fixed
I built the smallest app that shows the problem: one Node server that serves a JavaScript bundle with a role-based route guard, and a JSON API behind it. Two sessions: alice (role user) and root (role admin). Everything below is a box run on 18 October 2026 (Node 20.19.2), against localhost only. No real system was touched.
The bundle's guard is what most SPAs ship:
JavaScript
functionguard(route, me) {
if (!route.roles.includes(me.role)) returnnavigate('/403'); // UX onlyreturnrender(route);
}
The guard would have sent alice to /403. The API gave her the user list (function level) and bob's order (object level). In a browser she would never see these screens, which is exactly why teams miss this in manual QA.
Step 3: the fix is two server-side checks. (In the lab they sit behind a FIXED=1 switch so I can run both builds side by side.)
Alice keeps her own order, loses everything else, and root still works. The client guard did not change at all, and it did not need to.
Step 5: the CVE version check. A few lines of Node encode the GHSA ranges. Box run:
Text
$ node check-next.js 12.3.4 12.3.5 13.5.8 13.5.9 14.2.24 14.2.25 15.2.2 15.2.3 16.0.0
12.3.4 AFFECTED: upgrade
12.3.5 not in affected ranges
13.5.8 AFFECTED: upgrade
13.5.9 not in affected ranges
14.2.24 AFFECTED: upgrade
14.2.25 not in affected ranges
15.2.2 AFFECTED: upgrade
15.2.3 not in affected ranges
16.0.0 not in affected ranges
Feed it the next version from each lockfile you own. It checks one CVE, so it is not a substitute for npm audit or your dependency scanner.
A review checklist
List every route from the bundle and every endpoint the app calls.
Mark each endpoint public, authenticated, privileged or object-scoped.
Call each privileged endpoint as a low-privilege user, and each object-scoped one with another user's ID. Expect 403 or 404.
Confirm the check lives next to the data (handler, server function or data access layer), not only in middleware, a proxy or the router.
Turn each case into an integration test, as OWASP's API1 advice puts it: write tests for the authorization mechanism and "do not deploy changes that make the tests fail."
Keep framework versions patched, and alert on internal-only headers arriving from outside.
Limits
This is a pattern note, not a measurement of how common the bug is. Framework APIs move: the middleware-to-proxy rename above is Next.js 16 behaviour, and the Remix team now recommends React Router v7 for new projects and for upgrading Remix apps (Remix announcement), so check the docs for the major version you actually run.