fix(selfhost): stop client-spoofed cf-connecting-ip from bypassing rate limits - #6547
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (69.38%) is below the target coverage (99.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #6547 +/- ##
==========================================
+ Coverage 93.59% 95.79% +2.19%
==========================================
Files 672 591 -81
Lines 67622 47163 -20459
Branches 18591 15016 -3575
==========================================
- Hits 63289 45178 -18111
+ Misses 3360 1185 -2175
+ Partials 973 800 -173
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Caution 🛑 LoopOver review result - reject/close recommendedReview updated: 2026-07-16 13:12:59 UTC
Review summary Blockers
Nits — 5 non-blocking
Why this is blocked
📋 Copy for AI agents — paste into your coding agentCI checks failing
Decision drivers
Context & advisory signals — never blocks the verdict
Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
LoopOver is closing this pull request on the maintainer's behalf (CI is failing (codecov/patch, validate, validate-code); No linked issue detected; Maintainer requires a linked issue; AI reviewers agree on a likely critical defect: src/server.ts: the fix's entire self-host benefit depends on `nodeEnv?.incoming?.socket?.remoteAddress` matching the actual second-argument shape of the underlying `serve({fetch})` implementation; there is no test or visible import confirming that field path exists, and if it's wrong every Caddy-fronted request resolves to peer=undefined → resolveTrustedClientIp returns 'unknown-ip' → cf-connecting-ip is never set, collapsing ALL self-host traffic into one shared rate-limit bucket rather than just header-less clients as before.). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
Summary
RATE_LIMITER, butclientIp()still trustscf-connecting-ip. On Node that header is attacker-controlled (Caddy only sets X-Real-IP / X-Forwarded-For). Attackers can rotate it to bypass strict pre-auth buckets; honest clients without it collapse to a sharedunknown-ipbucket.serve({ fetch })edge, overwritecf-connecting-ipviawithTrustedClientIp: delete any client-supplied value; behind a private/link-local peer (Caddy) prefer X-Real-IP / leftmost XFF; on a public peer use the TCP address. Workers unchanged.Test plan
Risk / tradeoffs