Details
Note that no log line will show a header deletion because no deletion occurs. The X-User-Id and X-User-Role headers are never touched.
---
Impact
Any deployment using forward_auth with copy_headers where the auth service validates credentials without returning identity headers in its response. This is common in:
- Stateless JWT validators (verify signature, no response headers)
- Session validators that leave identity decoding to the backend
- Auth services where only some requests return identity headers
Attack:
- Attacker has any valid auth token
- Attacker sends request with forged
X-User-Id: adminandX-User-Role: superadmin - Auth service validates token, returns
200 OK, no identity headers - Caddy skips
Set(placeholder empty), never deletes original headers - Backend receives
X-User-Id: admin,X-User-Role: superadmin - Backend grants admin access
CVSS v3.1: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N = 8.1 High
---
Working Patch
--- a/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go
@@ -216,6 +216,25 @@ func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error)
copyHeaderRoutes := []caddyhttp.Route{}
for _, from := range sortedHeadersToCopy {
to := http.CanonicalHeaderKey(headersToCopy[from])
placeholderName := "http.reverse_proxy.header." + http.CanonicalHeaderKey(from)
+
+ // Security fix: unconditionally delete the client-supplied header
+ // before the conditional set runs. Without this, a client that
+ // pre-supplies a header listed in copy_headers can inject arbitrary
+ // values when the auth service does not return that header, because
+ // the MatchNot guard below skips the Set entirely (leaving the
+ // original client value intact).
+ copyHeaderRoutes = append(copyHeaderRoutes, caddyhttp.Route{
+ HandlersRaw: []json.RawMessage{
+ caddyconfig.JSONModuleObject(
+ &headers.Handler{
+ Request: &headers.HeaderOps{
+ Delete: []string{to},
+ },
+ },
+ "handler", "headers", nil,
+ ),
+ },
+ })
+
handler := &headers.Handler{
Request: &headers.HeaderOps{
Set: http.Header{
The delete route has no matcher, so it always runs. It fires before the existing MatchNot + Set route. The client-supplied header is cleared unconditionally. If the auth service provides the header, the subsequent Set then applies the correct value. If the auth service does not provide the header, the client's value is gone and the backend receives nothing.
This is a minimal, targeted fix with no impact on existing functionality when the auth service returns the headers.
---
Uniqueness Confirmation
The following were checked and confirmed not to cover this vulnerability:
- All 6 GHSA advisories published 2026-02-23: GHSA-x76f-jf84-rqj8, GHSA-g7pc-pc7g-h8jh, GHSA-hffm-g8v7-wrv7, GHSA-879p-475x-rqh2, GHSA-4xrr-hq4w-6vf4, GHSA-5r3v-vc8m-m96g
- GitHub issue #7459 (malformed Host header)
- GitHub issue #6610 (template placeholder leakage in copy_headers — fixed by PR #6608, which introduced this regression)
- All Caddy community forum threads on
forward_auth,copy_headers, and header stripping - CVE-2026-25748 (authentik auth bypass — root cause is in authentik cookie parsing, not Caddy)
- CVE-2024-21494, CVE-2024-21499 (caddy-security third-party plugin, not Caddy core)
- PR #6608 comment thread (no security discussion)
- cvedetails.com Caddy product listing (no matching CVE)
No prior report exists for this specific behavior.
---
References
- Vulnerable file (v2.11.1): https://github.com/caddyserver/caddy/blob/v2.11.1/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go
- PR #6608 (introduced regression): https://github.com/caddyserver/caddy/pull/6608
- Issue #6610 (related UX bug, fixed by PR #6608): https://github.com/caddyserver/caddy/issues/6610
- forward_auth documentation: https://caddyserver.com/docs/caddyfile/directives/forward_auth
---
Fix
Fix PR - https://github.com/caddyserver/caddy/pull/7545
---
AI Disclosure
An LLM was used to polish the report.