# Header-Based Access Control Bypass > Defeating an access gate that keys its decision on request metadata the client controls (override headers, client-IP headers, `Referer`, `Host`/`Origin`, framework-internal headers) or on a path the gate parses differently from the router behind it. ## How it works The gate and the handler see different requests. Either the gate trusts a header that only a proxy should set but that the client can send too, or a front component (WAF, reverse proxy, middleware) authorizes path *A* while the back end routes the same bytes to path *B*. Authorization at the "platform layer" (URL + method rules) is especially exposed, because the rule describes the request rather than the principal. ## Techniques / payloads **URL override headers** (PortSwigger: front-end blocks `/admin/deleteUser`, back-end honours the override): ``` POST / HTTP/1.1 X-Original-URL: /admin/deleteUser ``` Also `X-Rewrite-URL`. Pair with **method swaps** (`GET` for a `POST`-only deny rule). **Client-IP spoofing** against IP allowlists / "localhost only" admin: ``` X-Forwarded-For: 127.0.0.1 X-Real-IP: 127.0.0.1 X-Client-IP / X-Remote-IP / X-Originating-IP / True-Client-IP / CF-Connecting-IP: 127.0.0.1 ``` Try each independently and compare against a 403 baseline. The standardized `Forwarded:` header has the same problem: Rails, Spring and Jetty can be tricked into trusting spoofed client IP and host values when proxies don't strip it. **Referer gating**: sub-pages that only check `Referer: https://site/admin`. Same idea on storage: a Volcengine TOS bucket returned 403 with no or foreign Referer, and 200 with `Referer: https://<target-domain>/`, exposing 10+ GB of customer PII (**$6K**, chained with an unauthenticated upload signer). **Host/Origin allowlists on local services**: CircleCI's shared MCP server accepted any request with `Host: localhost` and no `Origin`. The check only stops browsers, and any non-browser client sets both (GHSA-xv5j-cwgj-22r4, unauthenticated RCE with the org's CircleCI token). Virtual-host probing (`Host: admin.target.com`, `X-Forwarded-Host`) finds unadvertised admin apps; see [[Host Header SSRF]]. **Framework-internal headers**: Next.js **CVE-2025-29927** (CVSS 9.1; < 13.5.9 / 14.2.25 / 15.2.3). The internal `x-middleware-subrequest` header, meant to stop middleware recursion, was accepted from external clients and skipped middleware entirely, including the auth/authz checks most apps put there. The exact header value varies by version. Self-hosted only; Vercel and Netlify weren't affected. Workaround: strip the header at the edge. **Path-matching differentials** (gate vs router): | Trick | Why it works | |---|---| | `/ADMIN/DELETEUSER` | router case-insensitive, gate case-sensitive | | `/admin/deleteUser.anything` | Spring `useSuffixPatternMatch` (default on before 5.3) | | `/admin/deleteUser/` | trailing slash treated as a distinct path by the gate | | `/static%2f..;/openidm/info/ping` | Jetty canonicalizes `%2f..;` for servlet selection while the WAF and outer rule see `/static/...`; reached ForgeRock OpenIDM and the Felix console `/static%2f..;/system%2fconsole;/bundles/.json` at two automakers | jhaddix's "403 bypass" list catalogues 77 such URL manipulations. BugQuest and Invicti both include method tampering and path variations as standard BAC checks. ## Notable cases - **Next.js CVE-2025-29927**: one header bypassed middleware auth across self-hosted Next.js. - **ForgeRock path confusion (Sam Curry et al.)**: WAF bypass to OpenIDM/AM admin surfaces, leading to RCE and remote vehicle access at two automakers. - **CircleCI MCP server**: Host/Origin "auth" defeated by curl. - **Volcengine TOS**: Referer as the only read control on a PII bucket, $6K. - **SaaS network ACL**: a related pattern where IP allowlists are per-user objects, removable via IDOR (see [[Privilege Escalation]]). ## Defenses - Never base authorization on client-settable headers. Derive client IP only from a trusted proxy hop count, and have the edge strip `X-Forwarded-*`, `Forwarded`, `X-Original-URL`, `X-Rewrite-URL` and framework-internal headers from inbound traffic. - Authorize in the application on the principal, not on URL patterns at a proxy. If you must use path rules, normalize once (decode, resolve dot segments, lowercase or reject mixed case, strip matrix params `;`) and make the gate and router share that normalizer. - Don't make middleware the *only* authz layer. Re-check in the handler or data layer ([[Function Level Authorization]]). - Local/dev servers (MCP, debug ports) need real authentication, not Host/Origin checks. ## Related - [[Authorization Security]] - [[Broken Access Control]] - [[Function Level Authorization]] - [[Host Header SSRF]] - [[URL Parser Differentials]] - [[MCP Security]] ## Sources - [[raw/portswigger.net/access-control-vulnerabilities-and-privilege-escalation-portswigger-2727|Access Control Vulnerabilities and Privilege Escalation - PortSwigger]] - [[raw/snyk.io/cve-2025-29927-authorization-bypass-in-next-js-middleware-9205|CVE-2025-29927 Authorization Bypass in Next.js Middleware]] - [[raw/infosecwriteups.com/header-manipulation-bypasses-probing-and-the-security-audit-nobody-doe-9157|Header Manipulation: Bypasses, Probing, and the Security Audit Nobody Does]] - [[raw/lkoskela.fi/forwarded-without-question-how-web-frameworks-overtrust-the-forwarded-13489|Forwarded Without Question: How Web Frameworks Overtrust the Forwarded Header]] - [[raw/x.com/403-bypass-list-by-jhaddix-url-manipulation-methods-top-77-ways-to-byp-1802|403 Bypass list by @jhaddix Url Manipulation Methods Top 77 ways to bypass access control #bugbountytip #bu...]] - [[raw/invicti.com/broken-access-control-how-to-detect-and-prevent-3694|Broken Access Control: How to Detect and Prevent]] - [[raw/intigriti.com/bugquest-2026-31-days-of-broken-access-control-2737|BugQuest 2026: 31 Days of Broken Access Control]] - [[raw/infosecwriteups.com/one-header-away-from-10-gb-of-customer-documents-pii-6k-bounty-10801|One Header Away from 10+ GB of Customer Documents (PII) — $6K Bounty]] - [[raw/remedio.io/unauthenticated-rce-in-circleci-s-mcp-server-host-origin-allowlist-byp-11489|Unauthenticated RCE in CircleCI's MCP server: Host/Origin allowlist bypassed by any non-browser client (GHS...]] - [[raw/samcurry.net/hacking-two-automakers-forgerock-path-confusion-rce-and-remote-vehicle-13612|Hacking Two Automakers: ForgeRock Path Confusion, RCE, and Remote Vehicle Access]] - [[raw/medium.com/privilege-escalation-via-idor-and-acl-bypass-in-saas-4309|Privilege Escalation via IDOR and ACL Bypass in SaaS]]