← Übersicht Traefik

ingress-nginx from-to-www-redirect sibling router serves the auth-protected backend without auth

GHSA-cjr6-pf59-jq29

Hoch GitHub: high Unbekannt Fix verfügbar

Veröffentlicht
27.08.2026 09:50
Zuletzt geändert
27.08.2026
EPSS (30 Tage)
unbekannt
CVSS-Vektor
keiner

Beschreibung

Originaltext der Quelle, nicht übersetzt.

## Summary There is a high severity vulnerability in Traefik's Kubernetes ingress-nginx provider. For an Ingress carrying both an authentication annotation and `nginx.ingress.kubernetes.io/from-to-www-redirect`, the provider created a second router matching on the host alone that carried only the `RedirectRegex` middleware while still pointing at the parent's protected backend service. `RedirectRegex` is not a terminal handler: a request its pattern does not match is forwarded to the next handler. Because the redirect pattern accepted only a numeric port while Traefik's host matcher canonicalizes any authority, a request carrying a non-numeric or empty port (`Host: www.example.com:x`) selected the sibling router, missed the redirect, and was proxied to the protected backend with none of the Ingress's annotation-derived middlewares applied. Authentication is not the only middleware lost: every annotation-derived middleware is discarded on that router, so source-IP allowlisting and the rest are equally absent. Traefik v2 is not affected, and neither is any v3 release before v3.7.0: the ingress-nginx provider's from-to-www-redirect handling was introduced in v3.7.0. ## Patches - https://github.com/traefik/traefik/releases/tag/v3.7.12 ## For more information If you have any questions or comments about this advisory, please [open an issue](https://github.com/traefik/traefik/issues). <details> <summary>Original Description</summary> # Traefik: the ingress-nginx from-to-www-redirect sibling router serves an auth-protected backend without auth **ANT-ID:** ANT-2026-EYY7M3H3 ## Summary For a Kubernetes Ingress carrying both an auth annotation and `nginx.ingress.kubernetes.io/from-to-www-redirect`, the ingress-nginx provider creates a second router that matches on the host alone, carries **only** the `RedirectRegex` middleware, and is pointed at the parent's real backend service. `RedirectRegex` is not a terminal handler: `pkg/middlewares/redirect/redirect.go` forwards every request its pattern does not match to the next handler, which for this router is the backend. The pattern cannot match an authority whose port is not numeric, while `net.SplitHostPort`, and hence the canonical host the `Host()` matcher compares against, accepts one. So `Host: www.example.com:x` selects the sibling router, misses the redirect, and is proxied to the protected backend with no authentication at all. Affects v3.7.10, the latest release, and HEAD. > Discovered by AI and verified by humans; credit Calif.io in collaboration with Anthropic. ## Technical Details `applyFromToWwwRedirect()` (`pkg/provider/kubernetes/ingress-nginx/translator.go:546`) is called immediately after `p.applyMiddlewares()` has populated `rt.Middlewares` with the Ingress's auth middleware. It then builds a new router that inherits `rt.Service` but replaces the middleware chain outright: ```go conf.HTTP.Routers[routerKey+"-from-to-www-redirect"] = &dynamic.Router{ EntryPoints: rt.EntryPoints, Rule: f.ExtraRouterRule, // Host("www.example.com"), no path constraint Priority: rt.Priority, Middlewares: []string{mwName}, // only the redirect; rt.Middlewares discarded Service: rt.Service, // the parent's protected backend TLS: rt.TLS, } ``` The authorization is not bypassed so much as never attached to that route, and because `applyMiddlewares()` is where every annotation-derived middleware is attached, the sibling discards all of them, not only BasicAuth. We confirmed the same 401-to-200 transition on an Ingress guarded by `whitelist-source-range` instead, which returns 403 on the parent and 200 on the sibling. What turns that into a reachable bypass is a disagreement between two parsers about the same authority. The redirect pattern is `(https?)://[^/:]+(:[0-9]+)?/(.*)`: `[^/:]+` stops at the first colon and `(:[0-9]+)?` accepts only digits, so for `http://www.example.com:x/admin/secret` the optional group matches empty and the pattern then requires `/` while the next character is still `:`. No match. Meanwhile `requestdecorator` derives the canonical host with `net.SplitHostPort`, which accepts that authority and yields `www.example.com`, so the `Host()` rule selects this router. The request therefore arrives at a router with no auth, fails to redirect, and falls through to `r.next`. A bare trailing colon (`Host: www.example.com:`) is sufficient; no exotic value is needed. Because the sibling rule carries no `PathPrefix`, paths that appear nowhere in the Ingress are reachable too, and the method is unconstrained. ## Reproduce ``` ./run.sh # ~2 min: builds traefik v3.7.10, runs the provider, drives the exploit ``` The harness writes no configuration by hand. `poc_dump_test.go` drives the real ingress-nginx provider over a fake Kubernetes API with an ordinary Ingress carrying `auth-type: basic` and `from-to-www-redirect`, and the configuration it emits is what the traefik binary then serves. The provider output shows the defect before any request is sent: a sibling router with `service: default-poc-protected-80` and `middlewares: [redirect only]`. ``` GET /admin/secret Host: example.com no creds -> 401 Unauthorized origin not reached GET /admin/secret Host: example.com creds -> 200 + secret origin reached GET /admin/secret Host: www.example.com:x no creds -> 200 + secret origin reached ``` The origin logs `BACKEND-RECEIVED request-line='GET /admin/secret HTTP/1.1' host='www.example.com:x'`, and the response carries the origin's own `X-Served-By` header and body, so the request was proxied rather than redirected. Four cases isolate the mechanism, each differing from the exploit in one respect: `Host: www.example.com` (no port) returns 302 with a correct `Location` and the origin is not reached; `Host: www.example.com:8080` (numeric port) likewise; `Host: unrelated.example.net:x` returns 404. The important one is `Host: example.com:x`, the same malformed authority sent to the **parent** router, which still returns 401. The malformed port is not itself an authorization bypass; it is a bypass only because it selects a sibling router that carries no authorization. ## Recommendations Two independent changes, either of which closes the reported path. The complete diff is in `suggested-fix.patch`. First, match the authority as everything up to the path, capturing only a numeric port, so a malformed or empty port canonicalises into a redirect instead of falling through: ```diff - Regex: `(https?)://[^/:]+(:[0-9]+)?/(.*)`, + Regex: `(https?)://[^/]*?(:[0-9]+)?/(.*)`, ``` Second, point the redirect-only router at the provider's existing 503 `unavailable-service` rather than at the protected backend. That router is never intended to proxy, and with no auth middleware on it any fall-through is by definition unauthenticated access, so this removes the class rather than the instance and also covers inputs the pattern cannot express. We recognise the second change alters provider output and updates four golden expectations in `kubernetes_test.go`. The first change alone fixes the reported trigger, so if you would rather take only that, it stands on its own; we are offering the second as defence in depth rather than pressing for it. > Patch verified: with both changes applied, every exploit case becomes a redirect with a > correct `Location` and the origin is never reached, while the 401, 200, 403 and both > redirect cases are unchanged. Upstream's own `go test > ./pkg/provider/kubernetes/ingress-nginx/...` passes. ## Notes for the reviewer - This is not a regression and not an incomplete patch. We checked the commits rather than inferring: `applyFromToWwwRedirect` is byte-identical at v3.7.7, v3.7.8 and v3.7.10, and the release that addressed GHSA-8rxv-jg7p-wvg3 touched only `rewrite_target.go`, `snippet/action.go` and `retry.go`. This is the same class left open by remediation that reviewed the path-rewriting middlewares. - One fidelity artifact of the harness, unrelated to the finding: `RedirectRegex.StatusCode` is `json:"-"`, so the provider's 308 is lost in the file-provider round trip and redirects show as 302 or 307 where a real cluster shows 308. The finding concerns requests that are not redirected. - We drove the real provider through a fake Kubernetes API rather than a live cluster. The provider code and the traefik binary are genuine; the cluster is not. - Reproduced on linux/arm64 with Go 1.26.0, which traefik's `go.mod` requires. This is routing and authorization logic with no architecture dependence. ## Artifacts | filename | purpose | |---|---| | `run.sh` | one command: build v3.7.10, generate the config from the provider, run all cases | | `poc_dump_test.go` | drives the real ingress-nginx provider over a fake Kubernetes API | | `poc.py` | the client; `--mode exploit\|control\|postfix` | | `backend.py` | instrumented origin that logs the raw request line it receives | | `poc-eyy7m3h3.yml` | the Ingress used | | `suggested-fix.patch` | both changes, with the golden-fixture updates | | `exploit_transcript.txt` | full request and response transcript, all cases | **PoC bundle:** https://drive.google.com/file/d/18_bwMG_GpvpxVqOeHbRagF4N63z8dehg/view?usp=sharing </details>

Betroffene Pakete im beobachteten Stack

Gogithub.com/traefik/traefik/v3v3.7.0 → v3.7.12GHSA-cjr6-pf59-jq29

Empfohlene Prüfung

  1. Feststellen, ob und in welcher Version die betroffenen Pakete in Ihren Systemen, Images und Abhängigkeiten vorkommen.
  2. Wo eine Fix-Version genannt ist: aktualisieren. Wo nicht: Hersteller-Advisory und Referenzen auf Workarounds prüfen.
  3. Erreichbarkeit beachten: Der Angriffsweg (Unbekannt) ist aus dem CVSS-Vektor abgeleitet.

Diese Seite sagt nichts darüber, ob Ihre Systeme betroffen sind. Das klärt erst eine Prüfung Ihrer Versionen.