/

CVE-2026-39858

Severity:

CRITICAL RISK

(10.0)

Authentication Bypass / Identity Spoofing in Traefik

CVE-2026-39858

Modified

Vulnerability type

Category:

Authentication Bypass / Identity Spoofing

CWE:

CWE-290, CWE-306, CWE-289

Impact:

Authentication Bypass on Protected Routes

Severity:

CRITICAL RISK

(10.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Traefik's ForwardAuth and snippet-based authentication middleware contain a header-handling flaw that allows attackers to spoof trust-related forwarded headers using underscore variants (e.g., X_Forwarded_Proto) that Traefik fails to sanitize.

When a downstream authentication backend treats underscore and dash header forms equivalently, an attacker can inject a fake trusted scheme or host and bypass authentication on routes that should require valid credentials.

Affected context

This vulnerability affects deployments where:

  • Traefik is used as an HTTP reverse proxy in front of applications protected by ForwardAuth or snippet-based authentication middleware, and
  • Traefik's forwarded-header sanitization is relied upon to present a trusted request context to an authentication backend, and
  • The authentication backend (or downstream app) normalizes or treats X-Forwarded-* and X_Forwarded_* headers as equivalent.

Under these conditions, alias headers using underscores can carry spoofed "trusted" attributes (such as scheme or host) past Traefik's sanitization logic and into the backend's trust decisions.

Exploit preconditions

  • Attack surface: HTTP(S) endpoints fronted by Traefik where ForwardAuth or snippet-based authentication middleware protects routes.
  • Required access: Network-level ability to send crafted HTTP requests directly to Traefik, including custom headers.
  • Trigger point: Submission of requests containing underscored alias headers (e.g., X_Forwarded_Proto, X_Forwarded_Host) that the backend normalizes into canonical X-Forwarded-* equivalents.
  • Why exploitation is possible: Traefik's sanitization logic only strips or overwrites canonical header names with dashes and does not normalize or remove underscored variants, while many backends merge or treat these variants as the same header and use them to infer "trusted" context (such as whether the original request was HTTPS or which host was addressed).

Why this happens

The root cause is incomplete normalization and sanitization of forwarded headers in Traefik's authentication-related middleware.

Traefik applies security logic to canonical X-Forwarded-* headers with hyphens, but it does not treat X_Forwarded_* underscore variants as equivalent or untrusted aliases.

This asymmetry creates a discrepancy between Traefik's trust model and that of typical backends, which may normalize header names or accept both forms when deriving security decisions.

Conceptually, this maps to CWE-290: Authentication Bypass by Spoofing, because the attacker can forge a trusted context (e.g., "this request is already authenticated and came over HTTPS") using headers that Traefik fails to sanitize, leading the backend to treat the request as legitimately authenticated.

It is closely related to CWE-306: Missing Authentication for Critical Function, since critical, protected routes can end up exposed without effective authentication when the spoofed headers convince the backend to skip checks.

Potential impact

  • Unauthorized access to endpoints that are intended to be protected by ForwardAuth or snippet-based authentication.
  • Bypass of single sign-on (SSO) or external authentication flows for specific routes or entire applications.
  • Impersonation of trusted request attributes (e.g., HTTPS scheme, internal host, or original client IP) that influence authorization logic.
  • Exposure of sensitive data or administrative interfaces to unauthenticated users.
  • Ability for attackers to pivot within internal services that rely on Traefik's sanitized headers for security decisions.

General mitigation guidance

Effective mitigation focuses on aligning header normalization across the proxy and backend and reducing trust in client-controlled forwarded headers:

  • Normalize header handling so that all variants of forwarded headers (dash and underscore forms) are treated consistently, ideally by rejecting or stripping unrecognized or ambiguous forms at the edge.
  • Harden authentication middleware and backends to avoid trusting client-supplied X-Forwarded-* or similar headers unless they originate from a known, authenticated proxy path.
  • Prefer explicit, secure context propagation mechanisms (such as dedicated authentication tokens, signed headers, or mTLS-based identity) over inferred trust from forwarded headers.
  • Apply a deny-by-default policy for non-canonical header names in security-sensitive code paths, including ForwardAuth integrations and custom middleware snippets.
  • Use least-privilege design on routes: even if a request appears "internal" or "already authenticated" based on headers, sensitive operations should still enforce strong, direct authentication and authorization.

How teams detect issues like this

Detection generally involves reviewing how forwarded headers are handled and ensuring header aliasing does not undermine authentication:

  • Static analysis / configuration review: Look for Traefik configurations and snippets that rely on X-Forwarded-* values to gate access, and verify that no logic considers underscore and dash variants equivalently without explicit sanitization.
  • Code review signals in backends: Identify frameworks or middleware that normalize header names (e.g., converting underscores to dashes) and then use X-Forwarded-* headers to decide whether to enforce authentication.
  • Security testing: Use automated or manual tests to send requests with both hyphenated and underscored forwarded headers, observing whether any authenticated-only route becomes accessible without valid credentials.
  • Monitoring and logging: Enable detailed access logs and authentication logs that include raw request headers where feasible, and set up alerts for anomalous patterns such as frequent use of X_Forwarded_* headers on protected endpoints.
  • Automated policy enforcement: Integrate HTTP gateway or WAF rules that normalize or drop ambiguous forwarding headers and flag configuration changes that weaken header sanitization behavior.

Sources

SourceLink
github.comgithub.com/traefik/traefik/releases/tag/v2.11.43
github.comgithub.com/traefik/traefik/releases/tag/v3.6.14
github.comgithub.com/traefik/traefik/releases/tag/v3.7.0-rc.2
github.comgithub.com/traefik/traefik/security/advisories/GHSA-5m6w-wvh7-57vm
access.redhat.comaccess.redhat.com/errata/RHSA-2026:21772
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-39858
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2464234
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-39858.json

Frequently asked

questions

Yes. Any attacker who can send HTTP(S) requests to a Traefik instance that uses ForwardAuth or snippet-based authentication can attempt to exploit the issue by crafting requests with underscored forwarded headers.

No. The core issue is that spoofed forwarded headers may cause the backend to treat unauthenticated requests as if they were already trusted. The attacker only needs network access to the Traefik endpoint and the ability to control request headers.

The safest pattern is to normalize and strictly sanitize all forwarded header variants at the edge, removing or overriding any client-controlled X-Forwarded-* and X_Forwarded_* headers, and to ensure that authentication decisions in backends do not depend on unsanitized, client-supplied forwarding headers.

Future prevention hinges on consistent trust modeling: treat any client-controlled header as untrusted by default, standardize header normalization between proxies and backends, rely on explicit authentication tokens or identities rather than inferred context from forwarding headers, and incorporate security-focused code and configuration reviews that specifically examine how proxies propagate trust-related metadata.

Find out what's already
exploitable in your codebase.