Let apps choose how the client IP on events is determined
Maintainer thường phản hồi trong vòng 2 ngày
@sl0thentr0py đang làm issue này rồi.
Từ ngày 4/11/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- Ruby
- Star
- 990
- Fork
- 552
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 29
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của getsentry/sentry-ruby
-
Bug Ruby
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
getsentry/sentry-ruby#3211 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Events dropped client-side for size are only logged at debug level and not recorded as lostCó thể đã có người làm @sentry-junior đã nhận hôm nay. Đang mởBug Junior: repro Ruby
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
getsentry/sentry-ruby#3209 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
with_child_span drops spans when blocks exit via break, return, or throwCó thể đã có người làm @itsrayeedscodespace đã nhận 1 ngày trước. Đang mởBug Ruby Traces Waiting for: Product Owner
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 38/100
getsentry/sentry-ruby#3206 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Remove `sentry-ruby-core` gemĐang mởbreaking change Next Major
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 58/100
getsentry/sentry-ruby#3176 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
With `register_error_subscriber`, view errors are reported twice: the wrapper by the middleware, and its cause by the error subscriberCó thể đã có người làm @sl0thentr0py đã nhận 13 ngày trước. Đang mởBug Ruby
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 57/100
getsentry/sentry-ruby#3166 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của getsentry/sentry-ruby
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
internetee/registry#2984 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ecosyste-ms/issues#862 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Redis Lua error `@user_script:52: ERR value is not an integer or out of range` when `window_size` is configuredCó thể đã có người làm @mimosa đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
riscv/riscv-unified-db#2829 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
⛓️ Security Difficulty: Easy Good First Issue Help Wanted ruby Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
rubyforgood/casa#7404 ·
Maintainer thường phản hồi trong vòng 1 ngày