{"id":"CVE-2026-54764","aliases":["CVE-2026-54764","GHSA-3q9r-p662-5j8m","GO-2026-6202"],"related":[],"kind":"vulnerability","state":"published","title":"ForwardAuth middleware leaks X-Forwarded-Port spoofing via untrusted X-Forwarded-Proto when trustForwardHeader=false","summary":"Traefik is an HTTP reverse proxy and load balancer. Prior to v2.11.51, v3.6.22, and v3.7.6, Traefik's ForwardAuth middleware, even when configured with trustForwardHeader: false, derives the X-Forwarded-Port header sent to the authentication service from the original incoming request instead of the sanitized forwarded request. As a result, an unauthenticated remote attacker can inject an X-Forwarded-Proto: https header over a plain HTTP connection and cause Traefik to forward X-Forwarded-Port: 443 to the authentication service, bypassing port-based authorization checks. This issue is fixed in versions v2.11.51, v3.6.22, and v3.7.6.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Traefik is an HTTP reverse proxy and load balancer. Prior to v2.11.51, v3.6.22, and v3.7.6, Traefik's ForwardAuth middleware, even when configured with trustForwardHeader: false, derives the X-Forwarded-Port header sent to the authentication service from the original incoming request instead of the sanitized forwarded request. As a result, an unauthenticated remote attacker can inject an X-Forwarded-Proto: https header over a plain HTTP connection and cause Traefik to forward X-Forwarded-Port: 443 to the authentication service, bypassing port-based authorization checks. This issue is fixed in versions v2.11.51, v3.6.22, and v3.7.6.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nThere is a medium severity vulnerability in Traefik's ForwardAuth middleware. Even when configured with `trustForwardHeader: false`, Traefik derives the `X-Forwarded-Port` header sent to the authentication service from the original incoming request instead of the sanitized forwarded request. As a result, an unauthenticated remote attacker can inject an `X-Forwarded-Proto: https` header over a plain HTTP connection and cause Traefik to forward `X-Forwarded-Port: 443` to the auth service, bypassing port-based authorization checks. This is a regression of the incomplete fix for GHSA-6384-m2mw-rf54, which addressed the `X-Forwarded-Proto` and `X-Forwarded-Prefix` spoofing vectors but missed the `X-Forwarded-Port` vector.\n\n## Patches\n\n- https://github.com/traefik/traefik/releases/tag/v2.11.51\n- https://github.com/traefik/traefik/releases/tag/v3.6.22\n- https://github.com/traefik/traefik/releases/tag/v3.7.6\n\n## For more information\n\nIf you have any questions or comments about this advisory, please [open an issue](https://github.com/traefik/traefik/issues).\n\n<details>\n<summary>Original Description</summary>\n\n### Summary\n\n  The ForwardAuth middleware, even when configured with `trustForwardHeader: false`,\n  still derives the `X-Forwarded-Port` header sent to the authentication service by\n  reading the **attacker-controlled** `X-Forwarded-Proto` header from the original\n  incoming request. This allows an unauthenticated remote attacker to cause Traefik\n  to forward `X-Forwarded-Port: 443` to the auth service on a plain HTTP connection,\n  creating an inconsistency that can bypass port-based authorization checks.\n\n  ### Details\n\n  The fix introduced in commit `5e1de2258` (released as part of the April 2026 security\n  advisory GHSA-6384-m2mw-rf54) correctly strips all X-Forwarded-* headers from the\n  forwarded auth request when `trustForwardHeader=false`, and reconstructs\n  `X-Forwarded-Proto` from the actual TLS state of the connection (`req.TLS`).\n\n  However, the reconstruction of `X-Forwarded-Port` is delegated to the helper\n  `forwardedPort(req)` which receives the **original request** (`req`) rather than\n  the sanitized forward request (`forwardReq`):\n\n  ```go\n  // pkg/middlewares/auth/forward.go – writeHeader()\n  if !trustForwardHeader {\n      forwardedheaders.DeleteXForwardedHeaders(forwardReq.Header) // strips all X-Fwd-* from forwardReq\n  }\n  // ...\n  if _, ok := forwardReq.Header[forwardedheaders.XForwardedPort]; !ok {\n      forwardReq.Header.Set(forwardedheaders.XForwardedPort, forwardedPort(req)) // ← req = ORIGINAL\n  }\n\n  // pkg/middlewares/auth/forward.go – forwardedPort()\n  func forwardedPort(req *http.Request) string {\n      if _, port, err := net.SplitHostPort(req.Host); err == nil && port != \"\" {\n          return port\n      }\n      // Reads attacker-controlled header on the ORIGINAL request:\n      if req.Header.Get(forwardedheaders.XForwardedProto) == \"https\" || ... {\n          return \"443\"\n      }\n      if req.TLS != nil {\n          return \"443\"\n      }\n      return \"80\"\n  }\n\n  Result when trustForwardHeader=false and attacker sends X-Forwarded-Proto: https\n  on a plain HTTP connection:\n\n  ┌──────────────────────────────────┬──────────┬────────┐\n  │ Header forwarded to auth service │ Expected │ Actual │\n  ├──────────────────────────────────┼──────────┼────────┤\n  │ X-Forwarded-Proto                │ http     │ http ✓ │\n  ├──────────────────────────────────┼──────────┼────────┤\n  │ X-Forwarded-Port                 │ 80       │ 443 ✗  │\n  └──────────────────────────────────┴──────────┴────────┘\n```\n  The inconsistency between Proto=http and Port=443 is exploitable against any\n  authentication service that gates access based on X-Forwarded-Port.\n\n  ### PoC\n\n  Traefik configuration:\n\n  ```http:\n    middlewares:\n      my-auth:\n        forwardAuth:\n          address: \"http://auth-service/\"\n          trustForwardHeader: false  # security setting, but still bypassable\n    routers:\n      api:\n        rule: \"PathPrefix(`/api`)\"\n        middlewares:\n          - my-auth\n        service: backend\n\n  Auth service logic (example victim):\n  # auth-service checks: only port 443 requests are considered \"secure\"\n  port = request.headers.get(\"X-Forwarded-Port\", \"80\")\n  proto = request.headers.get(\"X-Forwarded-Proto\", \"http\")\n  if port == \"443\":\n      return 200  # grant access\n  return 403\n```\n  Attack:\n\n  Plain HTTP connection, no TLS – but spoofs port 443\n  curl -H \"X-Forwarded-Proto: https\" http://traefik.example.com/api/admin\n  Auth service receives X-Forwarded-Port: 443 → grants access\n\n  Verification: Enable Traefik debug logging and observe X-Forwarded-Port: 443\n  in the auth request while the connection is plain HTTP.\n\n ### Impact\n\n  Any deployment using the ForwardAuth middleware with trustForwardHeader: false where\n  the downstream authentication service uses X-Forwarded-Port to make authorization\n  decisions is vulnerable to privilege escalation. An unauthenticated attacker can\n  bypass port-based security checks (e.g., \"only allow requests arriving on HTTPS port\n  443\") by injecting a single X-Forwarded-Proto: https header on a plain HTTP\n  connection.\n\n  This is a regression of the incomplete fix for GHSA-6384-m2mw-rf54: while the\n  X-Forwarded-Prefix and X-Forwarded-Proto spoofing vectors were addressed, the\n  X-Forwarded-Port vector was missed.\n\n</details>\n\n---","format":"markdown","source":"ghsa"},{"lang":"en","text":"Traefik: ForwardAuth middleware leaks X-Forwarded-Port spoofing via untrusted X-Forwarded-Proto when trustForwardHeader=false in github.com/traefik/traefik","format":"markdown","source":"go"}],"published":"2026-07-06T20:20:29.345Z","modified":"2026-08-18T15:10:51.913Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:L/SA:N","score":6.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:L/SA:N","score":6.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:L/A:N","score":5.8,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:L/SA:N","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:L/A:N","score":5.8,"rating":"MEDIUM"}],"cwes":["CWE-345"],"affected":[{"ranges":[{"version":"< 2.11.51","status":"affected"},{"version":">= 3.0.0, < 3.6.22","status":"affected"},{"version":">= 3.7.0, < 3.7.6","status":"affected"}],"vendor":"traefik","product":"traefik","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.11.51"}],"ecosystem":"Go","package":"github.com/traefik/traefik/v2","purl":"pkg:golang/github.com/traefik/traefik/v2","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"3.6.22"}],"ecosystem":"Go","package":"github.com/traefik/traefik/v3","purl":"pkg:golang/github.com/traefik/traefik/v3","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"3.7.0","status":"affected","fixed":"3.7.6"}],"ecosystem":"Go","package":"github.com/traefik/traefik/v3","purl":"pkg:golang/github.com/traefik/traefik/v3","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"1.7.34"}],"ecosystem":"Go","package":"github.com/traefik/traefik","purl":"pkg:golang/github.com/traefik/traefik","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/traefik/traefik","purl":"pkg:golang/github.com/traefik/traefik","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.11.51"}],"ecosystem":"Go","package":"github.com/traefik/traefik/v2","purl":"pkg:golang/github.com/traefik/traefik/v2","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"3.6.22"},{"type":"semver","introduced":"3.7.0","status":"affected","fixed":"3.7.6"}],"ecosystem":"Go","package":"github.com/traefik/traefik/v3","purl":"pkg:golang/github.com/traefik/traefik/v3","source":"go"},{"ranges":[{"status":"affected","fixed":"2.11.51"},{"status":"affected","introduced":"3.0.0","fixed":"3.6.22"},{"status":"affected","introduced":"3.7.0","fixed":"3.7.6"}],"vendor":"traefik","product":"traefik","cpe":"cpe:2.3:a:traefik:traefik:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/traefik/traefik/security/advisories/GHSA-3q9r-p662-5j8m","tags":["advisory","patch","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/traefik/traefik/pull/13344","tags":["fix","issue-tracking","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/traefik/traefik/commit/7ae92d8c2c10ac04ef5a03df0ed5019ce0f44b2d","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-54764","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/traefik/traefik","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/traefik/traefik/releases/tag/v2.11.51","tags":["web"],"sources":["ghsa","go"]},{"url":"https://github.com/traefik/traefik/releases/tag/v3.6.22","tags":["web"],"sources":["ghsa","go"]},{"url":"https://github.com/traefik/traefik/releases/tag/v3.7.6","tags":["web"],"sources":["ghsa","go"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-07-07T14:03:07.994Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-54764","url":"https://www.cve.org/CVERecord?id=CVE-2026-54764","licence":"CVE Terms of Use","modified":"2026-07-07T14:03:17.886Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3q9r-p662-5j8m","url":"https://github.com/advisories/GHSA-3q9r-p662-5j8m","licence":"CC-BY-4.0","modified":"2026-08-18T15:10:51.913Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-6202","url":"https://pkg.go.dev/vuln/GO-2026-6202","licence":"CC-BY-4.0","modified":"2026-08-18T15:00:24.133Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-54764","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-54764","licence":"Public domain","modified":"2026-07-08T03:01:46.417Z"}],"updatedAt":"2026-11-25T22:59:27.260Z","epss":{"score":0.00233,"percentile":0.15161,"date":"2026-12-01T12:00:22.000Z"}}