mirror of
https://github.com/bitbaum/limitkit.git
synced 2026-12-03 23:47:52 +01:00
clientIp returned the FIRST x-forwarded-for hop, with a comment asserting that was "what the proxy saw" and a test pinning it. Both were wrong in the same direction. A reverse proxy APPENDS to X-Forwarded-For. Caddy and nginx both do. So for a request through one proxy the header reads `<whatever the client sent>, <what the proxy actually saw>`, and the only entry a client cannot forge is the LAST. The effect, in every adopter at once: send a random X-Forwarded-For with each request and every request lands in a fresh bucket, so no bucket ever fills. Not "weakened" — bypassed completely. A limiter that cannot be tripped is not a limiter, and it is worse than none, because the route reads as protected. Found in orangecat's payments audit (bitbaum/orangecat#563, finding 2), where the same mistake is copied across three payment routes that each mint a real Lightning invoice per request. Now counts from the right. `trustedProxies` (default 1) says how many proxies of your own sit in front; a CDN in front of Caddy is 2 and moves the answer one further left. `trustedProxies: 0` means the server is exposed directly, so every forwarded header is client-written and none is evidence — the result is "unknown" rather than a number that looks like proof. Verified against the fleet's actual topology rather than assumed: DNS resolves straight to the box, no CDN, one Caddy 2.11.4 with no trusted_proxies configured, so exactly one hop is appended. BREAKING: the returned identity changes behind a proxy — which is the point. v0.2.0. Adopters pinning #v0.1.0 keep the bypass until they move. Claude-Session: https://claude.ai/code/session_018waGt1ieA9TjpscqrbrnGb Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>