Normalize raw remote IP addresses with ports#307
Open
Mishenevd wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
38f26de to
893558b
Compare
timokoessler
approved these changes
Jun 25, 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.
Summary
Normalize raw remote IP addresses before storing runtime user IPs.
In some servlet container configurations, the Java agent can receive a remote address in
ip:portformat through the raw request remote address path, not through theX-Forwarded-Forparser.This can happen with Spring Boot/Tomcat native forwarded-header handling: Tomcat consumes the
X-Forwarded-Forheader and exposes its value throughrequest.getRemoteAddr().Before this change, the fallback path returned
rawIpunchanged. As a result,SetUsercould store and report runtime user IPs like:This caused the same client IP to be reported as multiple different runtime user IPs when the source port changed.
Changes
Added normalization for fallback raw remote addresses.
Reused the same normalization for forwarded-header candidates.
Handles:
109.132.232.101:58780[2001:db8::1][2001:db8::1]:443Preserves the previous fallback behavior for values that cannot be parsed.
Testing
Targeted tests:
Covered cases:
X-Forwarded-Forwith bracketed IPv6 portSetUserusing the normalized IP from request contextLocal E2E smoke:
--server.forward-headers-strategy=nativeAIKIDO_TRUST_PROXY=falseX-Forwarded-For: 109.132.232.101:58780{ "remoteAddr": "109.132.232.101:58780", "xForwardedFor": null }Old agent behavior:
Fixed agent behavior:
Summary by Aikido
⚡ Enhancements
More info