Conversation
…nt IP Server spans in Node, Bun and Deno took `client.address` from the first `X-Forwarded-For` entry, with no check that the value is an IP. Events use `getClientIPAddress` for `user.ip_address`. That function checks the value and also reads other forwarding headers (`X-Real-IP`, `CF-Connecting-IP`, `Forwarded`, and more). So a span and the event for the same request could report different client IPs. Spans now use `getClientIPAddress` too. It is exported from `@sentry/core/server`. When the address comes from a forwarding header, the socket port belongs to the proxy, not to the client. `client.port` is now unset in that case. (It was previously the incorrect data, now it is blank, as it should be.) `network.peer.*` in Node still reports the socket values. Bun and Deno now pass the socket address to `sdkProcessingMetadata.ipAddress`, as Node does. Error events get `user.ip_address` when no forwarding header is present, and the `sentry.is_localhost` check works for direct loopback requests. Behavior changes: - Behind a proxy, server spans no longer have `client.port`. - A request with both `X-Client-IP` and `X-Forwarded-For` now reports the `X-Client-IP` value as `client.address`, the same as `user.ip_address` on events. This addresses the follow-up comments raised in #24523. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
isaacs
requested review from
JPeer264 and
mydea
and removed request for
a team
September 25, 2026 23:20
Contributor
size-limit report 📦
|
This branch has not been deployed
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.
Server spans in Node, Bun and Deno took
client.addressfrom the firstX-Forwarded-Forentry, with no check that the value is an IP. Events usegetClientIPAddressforuser.ip_address. That function checks the value and also reads other forwarding headers (X-Real-IP,CF-Connecting-IP,Forwarded, and more). So a span and the event for the same request could report different client IPs. Spans now usegetClientIPAddresstoo. It is exported from@sentry/core/server.When the address comes from a forwarding header, the socket port belongs to the proxy, not to the client.
client.portis now unset in that case. (It was previously the incorrect data, now it is blank, as it should be.)network.peer.*in Node still reports the socket values.Bun and Deno now pass the socket address to
sdkProcessingMetadata.ipAddress, as Node does. Error events getuser.ip_addresswhen no forwarding header is present, and thesentry.is_localhostcheck works for direct loopback requests.The vendored
getClientIPAddress(fromremix-utils) accepts only bare addresses, and it stays unchanged. A wrapper inpackages/core/src/utils/clientIPAddress.tsnormalizes the IP header values first. It strips a port (203.0.113.7:4711,[2001:db8::1]:4711), which Azure App Service sends inX-Forwarded-For. InForwarded, it removes quotes and matchesfor=in any case. Spans, events and the localhost check all use the wrapper, so they still agree.Behavior changes:
client.port.X-Client-IPandX-Forwarded-Fornow reports theX-Client-IPvalue asclient.address, the same asuser.ip_addresson events.This addresses the follow-up comments raised in #24523.