Skip to content

fix(ip): handle zoned IPv6 proxy peers - #3222

Merged
vishr merged 2 commits into
masterfrom
fix/proxy-ipv6-zones
Nov 12, 2026
Merged

vishr merged 2 commits into
masterfrom
fix/proxy-ipv6-zones

Conversation

@vishr

@vishr vishr commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #3179.

Normalize the direct peer's IPv6 zone once in extractIP, before validating a portless address. A small stripIPv6Zone helper handles the shared normalization, so direct, XFF, X-Real-IP, and legacy extraction use the same peer representation.

RemoteAddr -> split optional port -> remove IPv6 zone -> validate portless address
           -> existing proxy trust and forwarded-header parsing

No zone handling is added to forwarded-header parsing. Forwarded values containing zones remain invalid.

Related: #3180 and #3195.

Evidence

  • Before: a portless fe80::1%eth0 peer returns an empty IP. A zoned peer with a port prevents the header extractors from honoring a trusted proxy's client address on master.
    After: portless and host:port cases return fe80::1 directly, or client 203.0.113.5 when trust permits. Tests include multiple XFF hops, disabled link-local trust, missing headers, and rejected zones in forwarded values.
  • Independent branch: GOTOOLCHAIN=go1.27.4 go test -race ./..., go vet ./..., golint -set_exit_status ./..., and current staticcheck pass.

Merge Danger

Door: two-way

Blast Radius: proxies

Direct-peer results omit the local IPv6 zone. Trusted zoned peers can supply forwarded client addresses; untrusted peers still cannot. Forwarded-header validation remains strict.

@vishr
vishr merged commit 8255d6e into master Nov 12, 2026
11 checks passed
@vishr
vishr deleted the fix/proxy-ipv6-zones branch November 12, 2026 05:54
vishr added a commit that referenced this pull request Nov 12, 2026
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.

ExtractIPFromXFFHeader ignores X-Forwarded-For when the peer address has an IPv6 zone

1 participant