Skip to content

Fix trusted proxy client IP matching#139

Merged
JasonLovesDoggo merged 1 commit into
mainfrom
security-trusted-client-ip-bypass
May 14, 2026
Merged

Fix trusted proxy client IP matching#139
JasonLovesDoggo merged 1 commit into
mainfrom
security-trusted-client-ip-bypass

Conversation

@JasonLovesDoggo

Copy link
Copy Markdown
Owner

Impact

Defender previously evaluated r.RemoteAddr, the immediate peer address, instead of Caddy's resolved client_ip request variable. In deployments behind a trusted proxy, CDN, or load balancer, a blocked client could be allowed when the direct proxy address was not in a blocked range. This is a bypass of Defender's IP-based blocking policy for affected proxy deployments.

Patches

This patch makes Defender prefer Caddy's resolved client_ip value when present, with a fallback to RemoteAddr for direct request contexts. It also adds regression coverage for a blocked client_ip behind an unblocked direct peer.

Users should upgrade to the first release containing this patch.

Workarounds

Before upgrading, users can block the proxy or load balancer IP ranges directly, but that is usually too broad and may block legitimate traffic. Deployments that do not rely on trusted proxy client IP resolution are less exposed.

References

Validation

  • go test . -run TestDefenderServeHTTP_UsesCaddyClientIP -count=1
  • go test ./...

@JasonLovesDoggo JasonLovesDoggo marked this pull request as ready for review May 14, 2026 04:18
@JasonLovesDoggo JasonLovesDoggo force-pushed the security-trusted-client-ip-bypass branch from a8e19a0 to a85c489 Compare May 14, 2026 04:19
@JasonLovesDoggo JasonLovesDoggo merged commit 5b6e94e into main May 14, 2026
9 of 10 checks passed
@JasonLovesDoggo JasonLovesDoggo deleted the security-trusted-client-ip-bypass branch May 14, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant