CVE-2026-54764
JSON

6.9medium

ForwardAuth middleware leaks X-Forwarded-Port spoofing via untrusted X-Forwarded-Proto when trustForwardHeader=false

Severity
6.9medium CVSS:4.0 by GitHub_M
Exploit likelihood
0.23% (higher than 15% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-3q9r-p662-5j8mGO-2026-6202

Description

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.

Affected

Product or packageVersionsReported by
traefik traefik< 2.11.51, >= 3.0.0, < 3.6.22, >= 3.7.0, < 3.7.6, before 2.11.51, from 3.0.0 before 3.6.22, from 3.7.0 before 3.7.6CVE List, NVD
github.com/traefik/traefik/v2 (Go)before 2.11.51GitHub Advisory Database, Go Vulnerability Database
github.com/traefik/traefik/v3 (Go)before 3.6.22, from 3.7.0 before 3.7.6GitHub Advisory Database, Go Vulnerability Database
github.com/traefik/traefik (Go)up to 1.7.34, all versionsGitHub Advisory Database, Go Vulnerability Database

All scores

GitHub_M6.9medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:L/SA:N
GitHub5.8medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:L/A:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:L/SA:N
NVD5.8medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:L/A:N

Classification

CWE-345

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

What each source says

CVE List

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.

GitHub Advisory Database

Summary

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

Patches

For more information

If you have any questions or comments about this advisory, please open an issue.

<details> <summary>Original Description</summary>
Summary

The ForwardAuth middleware, even when configured with trustForwardHeader: false, still derives the X-Forwarded-Port header sent to the authentication service by reading the attacker-controlled X-Forwarded-Proto header from the original incoming request. This allows an unauthenticated remote attacker to cause Traefik to forward X-Forwarded-Port: 443 to the auth service on a plain HTTP connection, creating an inconsistency that can bypass port-based authorization checks.

Details

The fix introduced in commit 5e1de2258 (released as part of the April 2026 security advisory GHSA-6384-m2mw-rf54) correctly strips all X-Forwarded-* headers from the forwarded auth request when trustForwardHeader=false, and reconstructs X-Forwarded-Proto from the actual TLS state of the connection (req.TLS).

However, the reconstruction of X-Forwarded-Port is delegated to the helper forwardedPort(req) which receives the original request (req) rather than the sanitized forward request (forwardReq):

// pkg/middlewares/auth/forward.go – writeHeader()
if !trustForwardHeader {
    forwardedheaders.DeleteXForwardedHeaders(forwardReq.Header) // strips all X-Fwd-* from forwardReq
}
// ...
if _, ok := forwardReq.Header[forwardedheaders.XForwardedPort]; !ok {
    forwardReq.Header.Set(forwardedheaders.XForwardedPort, forwardedPort(req)) // ← req = ORIGINAL
}

// pkg/middlewares/auth/forward.go – forwardedPort()
func forwardedPort(req *http.Request) string {
    if _, port, err := net.SplitHostPort(req.Host); err == nil && port != "" {
        return port
    }
    // Reads attacker-controlled header on the ORIGINAL request:
    if req.Header.Get(forwardedheaders.XForwardedProto) == "https" || ... {
        return "443"
    }
    if req.TLS != nil {
        return "443"
    }
    return "80"
}

Result when trustForwardHeader=false and attacker sends X-Forwarded-Proto: https
on a plain HTTP connection:

┌──────────────────────────────────┬──────────┬────────┐
│ Header forwarded to auth service │ Expected │ Actual │
├──────────────────────────────────┼──────────┼────────┤
│ X-Forwarded-Proto                │ http     │ http ✓ │
├──────────────────────────────────┼──────────┼────────┤
│ X-Forwarded-Port                 │ 80       │ 443 ✗  │
└──────────────────────────────────┴──────────┴────────┘

The inconsistency between Proto=http and Port=443 is exploitable against any authentication service that gates access based on X-Forwarded-Port.

PoC

Traefik configuration:

  middlewares:
    my-auth:
      forwardAuth:
        address: "http://auth-service/"
        trustForwardHeader: false  # security setting, but still bypassable
  routers:
    api:
      rule: "PathPrefix(`/api`)"
      middlewares:
        - my-auth
      service: backend

Auth service logic (example victim):
# auth-service checks: only port 443 requests are considered "secure"
port = request.headers.get("X-Forwarded-Port", "80")
proto = request.headers.get("X-Forwarded-Proto", "http")
if port == "443":
    return 200  # grant access
return 403

Attack:

Plain HTTP connection, no TLS – but spoofs port 443 curl -H "X-Forwarded-Proto: https" http://traefik.example.com/api/admin Auth service receives X-Forwarded-Port: 443 → grants access

Verification: Enable Traefik debug logging and observe X-Forwarded-Port: 443 in the auth request while the connection is plain HTTP.

Impact

Any deployment using the ForwardAuth middleware with trustForwardHeader: false where the downstream authentication service uses X-Forwarded-Port to make authorization decisions is vulnerable to privilege escalation. An unauthenticated attacker can bypass port-based security checks (e.g., "only allow requests arriving on HTTPS port 443") by injecting a single X-Forwarded-Proto: https header on a plain HTTP connection.

This is a regression of the incomplete fix for GHSA-6384-m2mw-rf54: while the X-Forwarded-Prefix and X-Forwarded-Proto spoofing vectors were addressed, the X-Forwarded-Port vector was missed.

</details>
Go Vulnerability Database

Traefik: ForwardAuth middleware leaks X-Forwarded-Port spoofing via untrusted X-Forwarded-Proto when trustForwardHeader=false in github.com/traefik/traefik

References

Sources

SourceRecordLicence
CVE ListCVE-2026-54764 changed 2026-07-07CVE Terms of Use
GitHub Advisory DatabaseGHSA-3q9r-p662-5j8m changed 2026-08-18CC-BY-4.0
Go Vulnerability DatabaseGO-2026-6202 changed 2026-08-18CC-BY-4.0
NVDCVE-2026-54764 changed 2026-07-08Public domain