caddy/modules/caddyhttp/reverseproxy
newklei 2dbcdefbbe
forward_auth: copy_headers does not strip client-supplied identity headers (Fixes GHSA-7r4p-vjf4-gxv4) (#7545)
When using copy_headers in a forward_auth block, client-supplied headers with
the same names were not being removed before being forwarded to the backend.

This happens because PR #6608 added a MatchNot guard that skips the Set
operation when the auth service does not return a given header. That guard
prevents setting headers to empty strings, which is the correct behavior,
but it also means a client can send X-User-Id: admin in their request and
if the auth service validates the token without returning X-User-Id, Caddy
skips the Set and the client value passes through unchanged to the backend.

The fix adds an unconditional delete route for each copy_headers entry,
placed just before the existing conditional set route. The delete always runs
regardless of what the auth service returns. The conditional set still only
runs when the auth service provides that header.

The end result is:
  - Client-supplied headers are always removed
  - When the auth service returns the header, the backend gets that value
  - When the auth service does not return the header, the backend sees nothing

Existing behavior is unchanged for any deployment where the auth service
returns all of the configured copy_headers entries.

Fixes GHSA-7r4p-vjf4-gxv4
2026-03-03 23:30:49 -05:00
..
fastcgi chore: Enable modernize linter (#7519) 2026-02-26 14:01:35 -07:00
forwardauth forward_auth: copy_headers does not strip client-supplied identity headers (Fixes GHSA-7r4p-vjf4-gxv4) (#7545) 2026-03-03 23:30:49 -05:00
addresses.go core: Implement socket activation listeners (#6573) 2024-09-30 10:55:03 -06:00
addresses_test.go reverseproxy: do not parse upstream address too early if it contains replaceble parts (#5695) 2023-08-05 23:30:02 +02:00
admin.go api: Add all in-flight requests /reverse_proxy/upstreams (Fixes #7277) (#7517) 2026-03-03 15:14:55 -07:00
ascii.go reverseproxy: Sync up handleUpgradeResponse with stdlib (#4664) 2022-04-11 12:49:56 -06:00
ascii_test.go filesystem: Globally declared filesystems, fs directive (#5833) 2024-01-13 20:12:43 +00:00
buffering_test.go reverseproxy: more comments about buffering and add new tests (#6778) 2025-03-07 11:22:43 -07:00
caddyfile.go reverseproxy: Customizable dial network for SRV upstreams 2026-02-02 11:25:51 -07:00
command.go cmd: prevent commas in header values from being split (#7268) 2025-09-22 21:12:06 -06:00
copyresponse.go reverseproxy: Fix double headers in response handlers (#4847) 2022-06-22 15:10:14 -04:00
headers_test.go reverseproxy: fix X-Forwarded-* headers for Unix socket requests (#7463) 2026-02-10 13:00:20 -07:00
healthchecks.go reverseproxy: Fix health_port being ignored in health checks (#7533) 2026-03-03 13:10:54 -05:00
hosts.go reverseproxy: do not disable keepalive if proxy protocol is used (#7300) 2025-10-21 05:09:37 +00:00
httptransport.go caddyhttp: Avoid nil pointer dereference in proxyWrapper (#7521) 2026-02-25 04:08:41 -05:00
httptransport_test.go reverseproxy: fix tls dialing w/ proxy protocol (#7508) 2026-02-21 21:37:10 -05:00
metrics.go reverseproxy: ignore duplicate collector registration error (#6820) 2025-02-04 10:55:30 +03:00
reverseproxy.go api: Add all in-flight requests /reverse_proxy/upstreams (Fixes #7277) (#7517) 2026-03-03 15:14:55 -07:00
selectionpolicies.go chore: Enable modernize linter (#7519) 2026-02-26 14:01:35 -07:00
selectionpolicies_test.go reverseproxy: Allow 0 as weights for weighted_round_robin (#6681) 2024-11-07 17:58:31 -05:00
streaming.go chore: Enable modernize linter (#7519) 2026-02-26 14:01:35 -07:00
streaming_test.go reverseproxy: Add more debug logs (#5793) 2023-10-11 13:36:20 -06:00
upstreams.go use math/rand/v2 instead of math/rand (#7413) 2026-02-11 09:15:51 -07:00
upstreams_test.go chore: upgrade .golangci.yml and workflow to v2 (#6924) 2025-06-03 02:24:32 +03:00