Skip to content

Disable IP spoofing check in production - #127

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixconfig-stop-remoteip-spoof-check-49971d
Draft

Disable IP spoofing check in production#127
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixconfig-stop-remoteip-spoof-check-49971d

Conversation

@posthog

@posthog posthog Bot commented Aug 10, 2026

Copy link
Copy Markdown

Problem

  • Any client can force a 500 on the API by sending a Client-IP header — it is client-supplied, so the error is repeatable at will. Error tracking first saw it on 2026-08-10.
  • ActionDispatch::RemoteIp raises IpSpoofAttackError when Client-IP disagrees with X-Forwarded-For. Our chain is <cloudflare-edge>, <internal-docker-hop>, so a spoofed Client-IP fails the check.
  • The failure happens in 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.
  • Root cause is a config gap: config/environments/production.rb sets assume_ssl and force_ssl but never sets config.action_dispatch.ip_spoofing_check, so the check runs with its default of true.

Changes

+  config.action_dispatch.ip_spoofing_check = false
  • The app runs behind Cloudflare plus an internal Docker proxy, so the trusted client IP comes from the proxy, not from a client-supplied header. Turning the check off is the standard setting for this topology.

Alternatives considered

Option Note
ip_spoofing_check = false (chosen) Standard for an app behind Cloudflare; the header chain, not the client, is the source of truth.
Keep the check, add Docker ranges to trusted_proxies More config to maintain; still needs the internal ranges listed.

Risk

  • No code reads request.remote_ip for 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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants