Summary
A flaw in Traefik's StripPrefixRegex middleware allows specially crafted URLs with dot-segments to bypass ForwardAuth, BasicAuth, or DigestAuth protections.
When backends normalize these dot-segment paths, unauthenticated attackers may gain access to routes that were intended to be restricted.
Affected context
This vulnerability arises in Traefik deployments that rely on StripPrefixRegex in front of authentication mechanisms such as ForwardAuth, BasicAuth, or DigestAuth.
It is most relevant when backend services normalize dot-segments in paths (e.g., treating /./admin/secret as /admin/secret) according to RFC 3986.
In such setups, mismatched path handling between Traefik and the backend can lead to protected routes being exposed under certain URL constructions.
Exploit preconditions
- Attack surface: Publicly accessible HTTP endpoints served through Traefik where StripPrefixRegex is combined with an auth middleware.
- Required access: Network access to send HTTP requests to the Traefik instance; no prior authentication required.
- Trigger point: An HTTP request crafted so that the decoded path matches the StripPrefixRegex pattern, while the raw percent-encoded path includes dot-segments in the stripped prefix.
- Why exploitation is possible: Traefik matches against the decoded path but slices the raw path by byte length, producing a dot-segment path (e.g.,
/./admin/secret) that the auth middleware does not treat as protected, while the backend later normalizes it to the actual protected route.
Why this happens
The core issue is an inconsistency in how different components handle and interpret URL paths, mapping to CWE-706: Use of Incorrectly Resolved Name or Reference and CWE-22: Path Traversal-style dot-segment normalization behavior.
Traefik's StripPrefixRegex middleware uses the decoded URL path for regex matching but then applies the computed prefix length to slice the percent-encoded raw path.
When dots appear in the prefix, the resulting raw path after stripping can become a dot-segment path (/./...) that is sent to authentication middleware as-is.
Since the auth middleware bases its protection patterns on straightforward paths while backends later normalize dot-segments per RFC 3986, the two components disagree about which routes are protected, enabling authentication bypass.
Potential impact
- Unauthenticated users may gain access to administrative or internal application endpoints.
- Attackers could read or modify sensitive data exposed on protected routes.
- Security controls relying solely on Traefik authentication may be silently circumvented.
- Misconfiguration could allow lateral movement into internal services behind Traefik.
General mitigation guidance
Mitigation generally focuses on aligning URL handling semantics across the reverse proxy, auth middleware, and backend services and minimizing ambiguity in path processing.
Recommended patterns include:
- Ensuring that all components use consistent normalization rules for URL paths, especially regarding dot-segments.
- Avoiding reliance on path prefix stripping for security boundaries where subtle parsing differences may appear.
- Applying authentication checks on already-normalized paths or using explicit route-based protections instead of pattern-based prefix logic.
- Reducing trust in user-controlled URL components and treating complex encodings or dot-segments as suspicious inputs.
- Designing backends to enforce their own authorization checks even when fronted by a proxy, so that proxy misrouting cannot grant broad access.
How teams detect issues like this
Detection efforts can focus on identifying inconsistent path handling and unexpected access patterns:
- Static analysis and configuration review to flag uses of StripPrefixRegex in combination with authentication middleware, especially where dot-segment paths might be produced.
- Code review signals such as separate logic for decoded versus raw URL paths, or length-based slicing of encoded paths used for security-relevant routing.
- Security tests that fuzz URLs with percent-encoding, dots, and path traversal-like segments to verify that authentication still applies.
- Runtime monitoring for unusual access patterns, such as requests using
/./segments reaching endpoints that should be restricted. - Automated configuration scanners or policy enforcement tools that highlight ambiguous path normalization or mismatched protection rules between proxy and backend.

