Let apps choose how the client IP on events is determined
メンテナーはふだん 2 日以内に返信
@sl0thentr0py がすでに取り組んでいます。
2026年11月4日 から。
評価
この issue はまだ評価されていません。
説明
Problem Statement
With send_default_pii (data_collection.user_info in 7.x), Event#rack_env= sets user[:ip_address] from Utils::RealIp. It puts Client-IP and X-Real-IP first, then X-Forwarded-For from the right, then REMOTE_ADDR, and takes the first address that isn't a trusted proxy.
Some platforms pass those headers through from the client. Heroku's router, for one, appends the address it saw to X-Forwarded-For and passes Client-IP and X-Real-IP on as the client sent them. A client that sends Client-IP: 198.51.100.2 gets that address on its events, and the address the router saw is never used. trusted_proxies can't help: it only removes the listed proxies' addresses from those candidates, and the Client-IP value is whatever the client wrote, not a proxy, so it stays first.
real_ip.rb says spoofing "only makes data inaccurate, not insecure", and accuracy is the problem here: on such a platform the IP on an event is whatever the client chose. Only the app knows its topology, and so which header to read: the last X-Forwarded-For entry on Heroku, Fly-Client-IP on Fly.io, CF-Connecting-IP behind Cloudflare.
The only way we found that keeps the SDK's own rules is to override the private Event#calculate_real_ip_from_rack(env):
module ClientIP
private
def calculate_real_ip_from_rack(env)
env["HTTP_X_FORWARDED_FOR"]&.split(",")&.last&.strip # Heroku
end
end
Sentry::Event.prepend(ClientIP)
The SDK still decides when an event gets an address, and keeps one set with Sentry.set_user (#2350). But the method is private: a rename quietly brings back the header-based address, and a new argument makes every event from a web request fail to build, so capture_event drops it. The public alternatives fall short. A global event processor has to repeat the SDK's rules for each version, and in 5.x it also receives LogEvents, which have no request. Sentry.set_user(ip_address: ...) is replaced by any later set_user call in the app.
Solution Brainstorm
A supported way for the app to supply the address, called where calculate_real_ip_from_rack is today, so the SDK's checks stay as they are. For example, a callable:
Sentry.init do |config|
config.send_default_pii = true
# Called with the Rack env when the SDK adds the user's IP address
config.real_ip = ->(env) { env["HTTP_X_FORWARDED_FOR"]&.split(",")&.last&.strip }
end
That would also cover #2592: an app whose clients are on a private network could return their address without changing how trusted_proxies and LOCAL_ADDRESSES work for everyone else. A narrower option that picks the headers RealIp reads would fix the precedence, but not #2592.
We checked sentry-ruby 5.25, 5.28, 6.7 and 7.2, which all work out the address this way.
- 主要言語
- Ruby
- スター
- 990
- フォーク
- 552
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 29
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-ruby のほかの issue
-
Bug Ruby
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-ruby#3211 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Events dropped client-side for size are only logged at debug level and not recorded as lost対応中かも @sentry-junior が今日担当しました。 オープンBug Junior: repro Ruby
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-ruby#3209 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
-
with_child_span drops spans when blocks exit via break, return, or throw対応中かも @itsrayeedscodespace が 1 日前に担当しました。 オープンBug Ruby Traces Waiting for: Product Owner
難易度 2/5 1〜3時間 初心者へのやさしさ 38/100
getsentry/sentry-ruby#3206 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
breaking change Next Major
難易度 2/5 1〜3時間 初心者へのやさしさ 58/100
getsentry/sentry-ruby#3176 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
With `register_error_subscriber`, view errors are reported twice: the wrapper by the middleware, and its cause by the error subscriber対応中かも @sl0thentr0py が 13 日前に担当しました。 オープンBug Ruby
難易度 4/5 1〜2日 初心者へのやさしさ 57/100
getsentry/sentry-ruby#3166 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
getsentry/sentry-ruby の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
internetee/registry#2984 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ecosyste-ms/issues#862 ·
メンテナーはふだん 1 日以内に返信
-
Redis Lua error `@user_script:52: ERR value is not an integer or out of range` when `window_size` is configured対応中かも @mimosa が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
riscv/riscv-unified-db#2829 ·
メンテナーはふだん 1 日以内に返信
-
⛓️ Security Difficulty: Easy Good First Issue Help Wanted ruby Type: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
rubyforgood/casa#7404 ·
メンテナーはふだん 1 日以内に返信