Skip to content

Harden forwarded client IP selection - #414

Merged
linkdata merged 3 commits into
mainfrom
fix/forwarded-client-ip-last-hop
Sep 25, 2026
Merged

linkdata merged 3 commits into
mainfrom
fix/forwarded-client-ip-last-hop

Conversation

@linkdata

@linkdata linkdata commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Use the rightmost address in the last X-Forwarded-For header value, matching the address appended by one trusted proxy. Fall back to the rightmost address in the last X-Real-IP value. If both valid addresses disagree, use the transport peer.

This changes IP binding for multi-address X-Forwarded-For chains and conflicting IP headers. Proxies must set or remove both IP headers; controlling only one lets a client force transport-peer binding.

Tests cover appended and duplicate headers, conflicting headers, and the pending-request cap with forged prefixes.

Fixes #401.

Validation

  • go generate ./...
  • go test -race ./...
  • go test ./...
  • go vet ./...
  • go build ./...
  • CI-pinned staticcheck ./...
  • golangci-lint run
  • gosec -quiet ./...
  • gofumpt -l serve.go jaws_test.go

@linkdata
linkdata merged commit edd11fe into main Sep 25, 2026
7 checks passed
@linkdata
linkdata deleted the fix/forwarded-client-ip-last-hop branch September 25, 2026 18:53
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.

Needs a check: forwardedClientIP takes the leftmost X-Forwarded-For entry

1 participant