/

CVE-2026-30851

Severity:

HIGH RISK

(8.1)

Improper Authentication / Identity Injection in Caddy

CVE-2026-30851

Analyzed

Vulnerability type

Category:

Improper Authentication / Identity Injection

CWE:

CWE-287, CWE-345

Impact:

Authentication Bypass and Privilege Escalation via Trust of Spoofed Identity Headers

Severity:

HIGH RISK

(8.1)

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

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_auth module to delegate authentication to an upstream service, and
  • Use the copy_headers configuration 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_auth for access control, and
  • Rely on copy_headers to 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_headers logic 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_auth and copy_headers to 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.

Sources

SourceLink
github.comgithub.com/caddyserver/caddy/issues/6610
github.comgithub.com/caddyserver/caddy/pull/6608
github.comgithub.com/caddyserver/caddy/pull/7545
github.comgithub.com/caddyserver/caddy/security/advisories/GHSA-7r4p-vjf4-gxv4

Frequently asked

questions

Exploitability depends on how the deployment uses forward_auth and which headers are trusted downstream. If downstream services treat forwarded headers as authoritative identity or role indicators, any client who can reach the Caddy instance and craft HTTP headers may be able to exploit the issue.

Not necessarily. The attacker primarily needs network access to the affected Caddy endpoint and knowledge or guesswork about which headers are trusted by downstream services. In many configurations, this can be achieved without pre-existing credentials.

Ensure that identity and authorization headers are generated and controlled exclusively by the authentication component or proxy, not by clients. Strip all client-supplied versions of these headers and have the proxy explicitly set them based on verified authentication results, overwriting any incoming values.

Define a clear trust model for authentication data: decide which components are allowed to assert identity, ensure those components sign or otherwise protect identity information, and treat all client-provided identity headers as untrusted input. Enforce this model using configuration standards, automated linting, and regular security reviews of reverse proxy and authentication setups.

Find out what's already
exploitable in your codebase.