Disable IP spoofing check in production - #127
Draft
posthog[bot] wants to merge 1 commit into
Draft
Conversation
The app runs behind Cloudflare and an internal Docker proxy. Rails' ActionDispatch::RemoteIp raises IpSpoofAttackError when a request sends a Client-IP header that disagrees with X-Forwarded-For, which returns a 500 before the request reaches a controller. Because Client-IP is client-supplied, any client can trigger the error at will. Set config.action_dispatch.ip_spoofing_check = false, the standard setting for an app behind Cloudflare, where the trusted client IP comes from the proxy and never from a client-supplied header. Generated-By: PostHog Code Task-Id: f28b7132-79cc-4246-957b-9a634dfb338f
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.
Problem
Client-IPheader — it is client-supplied, so the error is repeatable at will. Error tracking first saw it on 2026-08-10.ActionDispatch::RemoteIpraisesIpSpoofAttackErrorwhenClient-IPdisagrees withX-Forwarded-For. Our chain is<cloudflare-edge>, <internal-docker-hop>, so a spoofedClient-IPfails the check.Rails::Rack::Logger#started_request_message, before the request reaches a controller. No data loss, no broken flow — the guard is a Rails safety check, not a vulnerability.config/environments/production.rbsetsassume_sslandforce_sslbut never setsconfig.action_dispatch.ip_spoofing_check, so the check runs with its default oftrue.Changes
+ config.action_dispatch.ip_spoofing_check = falseAlternatives considered
ip_spoofing_check = false(chosen)trusted_proxiesRisk
request.remote_ipfor a security decision (verified with a repo-wide search), so relaxing the check does not weaken any access control.Created with PostHog Desktop from this inbox report.