carlos / platform Public

Fleet apps see the hub's address, not the client's (Tito Classic/Pro) Issue open

From Tito's infrastructure session, for Paul. This blocks Tito's move off Kubernetes.

What happens: fleet apps behind the hub see the hub's public address as the client.

  • Classic on Tito production CARLOS (fleet tito-production, hub IE, v0.40.2) logs ip=54.228.234.85, IE's EIP, for every request.
  • Staging Pro logs 40.180.24.110, the staging hub's EIP.

Why it matters: Rails' request.remote_ip, Rack::Attack and app logic all key on the client address:

  • Classic's Allow2Ban (24 h bans), its per-IP throttles, the blocked-IP list and the IP-reputation check on signup (dashboard-tito #2663)
  • Pro's 600 reads/min per IP

Behind the fleet, one bad client gets everyone banned, and the per-IP limits become one global limit. Staging Pro answered 429 above about 10 req/s in a load test.

Ask: pass the real client address through the hub to the fleet box and app, in a form Rails trusts by default: X-Forwarded-For with the hub, tunnel and edge addresses trusted, or the PROXY protocol, or similar. Document what an app should trust. #416 covers forwarding between apps, not this case.

Picked up by a platform builder session (routed from 8a3d302 on Paul's go). Rough date: built, reviewed and merged on main by 2026-11-23. Live needs a release and a roll of the fleet boxes, which is Paul's go; the hub itself needs no change.

Cause, confirmed in code. The hub already sends the box the client it saw: every hub-to-tunnel proxy runs tunnelRewrite, whose setForwarded writes X-Forwarded-For fresh (ReverseProxy's Rewrite drops whatever the client sent), so the chain ends in the hub's own view of the client (the PPv2 address on the region NLBs, or the believed chain on a verified backhaul hop). The fleet box then throws it away: its own setForwarded believes an inbound chain only on a verified mesh hop or a linked request, so for a tunnelled request it writes the tunnel peer, the hub.

Design note (small; no spec). The box treats a tunnelled request the way it already treats a linked one (linked deployments §6.2), which is the trust rule #476 sketched:

  • Trust boundary: only requests that arrived on a tunnel this box dialled to its configured hub (tunnelclient's own context mark, which nothing in a request can set). On the box's public listener X-Forwarded-For stays the client's to forge and is replaced, as today.
  • What the app gets: the hub's X-Forwarded-For chain, normalised, when every entry is an IP address; otherwise the connection peer, as now. The box's forwarded-for proof signs the chain as sent.
  • The box's password gate keys its attempt limiter on the chain's last entry (the client the hub saw), not the shared tunnel address.
  • Covers fleet channels and static -tunnel channels alike, plain HTTP and WebSockets (the upgrade rides the same proxy).
  • Unchanged: the platform's own analytics, rate limits, protection and request records already run at the hub and skip tunnelled requests on the box.

What an app should trust (goes in the docs, after a copy pass): the same contract a shared-box app already has. The edge reaches the app on its unix socket and sends X-Forwarded-For with the client as the last entry, the edge having removed anything the client sent. Rails' request.remote_ip and Rack::Attack's req.ip pick that entry with default settings; I will confirm both against a real Rails app before the docs say so.

Test-first: an end-to-end test (hub edge, real tunnel, box edge, app socket) where a client forges X-Forwarded-For and the app must see exactly the hub's view of the client.

Merged on main as 74aeb271 (2026-11-22). Not released; releases and rolls are Paul's go.

What changed: for a request that arrived over a tunnel the box dialled, the fleet box's edge now passes the hub's X-Forwarded-For chain to the app (when every entry is an IP address) instead of the tunnel peer, and the password gate's attempt limiter keys on the chain's last entry. Off a tunnel nothing changes. The hub needs no change; only the fleet boxes need the new build (for Tito: the tito-production and staging fleet boxes).

What apps see: X-Forwarded-For whose last entry is the client the hub saw. Rails request.remote_ip and Rack::Request#ip (Rack::Attack's req.ip) return it with default settings; checked against the Puma 8, actionpack 8.1 and rack 3.2 sources. Docs: rootfs "The visitor's address", with a pointer from the Rails guide.

Review: Astra R1 READY with no findings, plus READY on a refactor for the code-health line budget. Census fleet-client-address-1348 approved on #280. Tests: internal/edge/tunnelclientaddr_test.go runs a real hub edge, tunnel loop and box edge for plain HTTP and a WebSocket upgrade, plus the fallbacks and gate keys. The existing linked-request gate test had the same -race timing flake and was fixed the same way.

Witness once rolled: on a fleet app, the app's log of request.remote_ip (or the X-Forwarded-For it receives) shows the visitor's address, not the hub's EIP. A staging Pro load test should then be limited per client, not globally.