Repository navigation
fix: GetClientIP discards real IP on multi-hop X-Forwarded-For and leaves a port on the RemoteAddr fallback - #7101
Merged
Conversation
|
Bito Automatic Review Skipped - Draft PR |
bhupesh-devtron
marked this pull request as ready for review
November 27, 2026 08:00
bhupesh-devtron
requested review from
prakarsh-dt and
vivek-devtron
as code owners
November 27, 2026 08:00
|
Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n |
|
Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n |
prakash100198
previously approved these changes
Nov 27, 2026
bhupesh-devtron
dismissed
prakash100198’s stale review
November 30, 2026 12:27
The base branch was changed.
…aves a port on the RemoteAddr fallback GetClientIP previously returned the X-Forwarded-For header verbatim (unusable once more than one hop is present) and fell back to RemoteAddr including its port when no proxy header was set. It now takes the rightmost X-Forwarded-For entry (the nearest trusted proxy's own observed peer, not the client-claimed leftmost one - which a client-appending proxy like AWS ALB would let the client fake), falls back to X-Real-IP, then RemoteAddr, stripping the port from whichever entry is used via a shared stripPort helper (handles bracketed IPv6 too). Ported from the equivalent devtron-enterprise fix (PR #3450).
bhupesh-devtron
force-pushed
the
fix/get-client-ip-xff-parsing
branch
from
November 30, 2026 12:34
af85dfd to
d5ef3ba
Compare
|
prakash100198
approved these changes
Dec 2, 2026
vivek-devtron
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



GetClientIP previously returned the X-Forwarded-For header verbatim (unusable once more than one hop is present) and fell back to RemoteAddr including its port when no proxy header was set. It now takes the rightmost X-Forwarded-For entry (the nearest trusted proxy's own observed peer, not the client-claimed leftmost one - which a client-appending proxy like AWS ALB would let the client fake), falls back to X-Real-IP, then RemoteAddr, stripping the port from whichever entry is used via a shared stripPort helper (handles bracketed IPv6 too).
Description
Fixes https://github.com/devtron-labs/sprint-tasks/issues/3005
Checklist:
Does this PR introduce a user-facing change?