Summary
Caddy's forward_auth copy_headers feature between versions 2.10.0 and 2.11.1 fails to strip client-supplied authentication-related headers before forwarding them to upstream services.
An attacker who can send crafted HTTP requests to a Caddy instance using forward_auth may inject or override identity headers, leading to authentication bypass and privilege escalation in downstream applications that trust these headers.
Affected context
This vulnerability appears in Caddy deployments that:
- Use the
forward_authmodule to delegate authentication to an upstream service, and - Use the
copy_headersconfiguration to forward identity or authorization headers, and - Have downstream services (or the auth backend itself) that implicitly trust specific HTTP headers (e.g., user ID, roles, or auth status) as proof of identity.
The issue becomes relevant where client-controlled headers are not sanitized, and downstream components treat those headers as authoritative authentication or authorization information.
Exploit preconditions
- Attack surface: HTTP(S) endpoints exposed by Caddy that:
- Use
forward_authfor access control, and - Rely on
copy_headersto propagate identity/authorization headers. - Required access: Ability to send HTTP requests to the affected Caddy instance (typically network access; no prior authentication may be required if the protected route is the first gate).
- Trigger point: The attacker includes crafted identity or authorization headers in the incoming request (for example, headers normally added only by a trusted auth service); Caddy's
forward_auth copy_headerslogic forwards them without stripping or overriding them. - Why exploitation is possible: The proxy layer does not distinguish between headers set by the client and headers intended to originate only from a trusted authentication component. Downstream services then accept these copied headers as valid identity or privilege assertions, enabling authentication bypass or escalation.
Why this happens
The core issue is an improper authentication and trust boundary violation between the edge proxy and the authenticated identity source.
Caddy's forward_auth copy_headers mechanism copies specified headers from the authentication response but does not sanitize or remove equivalent headers that were already present on the client request. This creates a confusion where downstream components cannot reliably tell whether an identity/role header came from the trusted auth backend or from the untrusted client.
Conceptually, this maps to:
- CWE-287: Improper Authentication — authentication decisions are influenced by untrusted data (client-supplied headers) that are treated as if they were produced by a trusted authority.
- CWE-345: Insufficient Verification of Data Authenticity — the system fails to verify the origin and authenticity of headers that are supposed to represent user identity or authorization state.
Potential impact
- Attackers may spoof user identity headers to impersonate other users.
- Privilege escalation by injecting headers that indicate elevated roles (e.g., admin or service account).
- Bypass of single sign-on (SSO) or centralized auth flows that rely on trusted headers.
- Unauthorized access to protected APIs, admin panels, or internal dashboards.
- Indirect data exfiltration or modification in downstream services that trust these headers.
General mitigation guidance
Mitigations generally focus on re-establishing a clear trust boundary for identity headers and ensuring downstream services only consume trusted identity sources:
- Prefer designs where the reverse proxy overwrites or sets identity headers explicitly based on the result of authentication, never copying or preserving client-supplied versions of those headers.
- Implement header sanitization at the edge: strip or rename all potentially sensitive identity/authorization headers from incoming client requests before invoking auth or forwarding to backends.
- Standardize a set of "trusted" headers (e.g.,
X-User-ID,X-User-Roles) that only the auth component is allowed to emit; treat any client-provided instance of those headers as untrusted and remove them. - Use defense-in-depth on downstream services:
- Do not trust identity purely from headers when possible.
- Where headers must be used, validate them against signed tokens or session state, or ensure they are only accepted on internal, authenticated channels.
- Apply least privilege and explicit checks in backend applications so that a single spoofed header does not automatically grant broad administrative rights.
How teams detect issues like this
Detection centers on identifying untrusted header usage and inconsistent identity handling across proxy and application layers:
- Static configuration review:
- Examine Caddy configurations using
forward_authandcopy_headersto identify cases where authentication or role headers are forwarded. - Flag configurations that do not clearly strip client-supplied equivalents of those headers at the edge.
- Code review in downstream services:
- Look for logic that bases authentication or authorization solely on HTTP headers without verifying their origin (e.g., trusting
X-User,X-Email,X-Role, or custom identity headers). - Identify patterns where header content is used to select user accounts or privilege levels without cryptographic verification.
- Policy-based scanning:
- Use configuration linters or security policy engines to enforce rules such as "identity headers must be overwritten, not passed through from the client."
- Runtime monitoring:
- Log and monitor identity-related headers, especially when they appear on requests from untrusted networks.
- Alert on anomalous combinations, such as unauthenticated requests carrying high-privilege identity headers.
Automated configuration and code review tools can help consistently surface misuse of identity headers, particularly in large or multi-service deployments.

