Skip to content

Commit ab5d1d4

Browse files
committed
Move TrackTrueClientIp middleware into saas engine
The True-Client-IP header is set by Cloudflare and is only trustworthy when behind a Cloudflare proxy. In non-Cloudflare deployments, this header is attacker-controlled and can be used to spoof IP addresses. Moving the middleware into the saas engine ensures it only loads for our Cloudflare-fronted production deployment, not for self-hosted OSS instances. GHSA-cpch-9qg2-x8fq
1 parent 723c818 commit ab5d1d4

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

saas/lib/fizzy/saas/engine.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require_relative "transaction_pinning"
2+
require_relative "true_client_ip"
23
require_relative "signup"
34
require_relative "authorization"
45
require_relative "gvl_instrumentation"
@@ -61,6 +62,10 @@ class Engine < ::Rails::Engine
6162
app.config.middleware.insert_after(ActiveRecord::Middleware::DatabaseSelector, TransactionPinning::Middleware)
6263
end
6364

65+
initializer "fizzy_saas.true_client_ip" do |app|
66+
app.config.middleware.insert_before ActionDispatch::RemoteIp, TrackTrueClientIp
67+
end
68+
6469
initializer "fizzy_saas.gvl_instrumentation" do |app|
6570
app.config.middleware.insert_before(Rack::Runtime, GvlInstrumentation)
6671
end
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@ def call(env)
2020
@app.call(env)
2121
end
2222
end
23-
24-
Rails.application.config.middleware.insert_before ActionDispatch::RemoteIp, TrackTrueClientIp

0 commit comments

Comments
 (0)