mirror of
https://github.com/bitbaum/limitkit.git
synced 2026-12-04 02:47:50 +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>
58 lines
1.4 KiB
JSON
58 lines
1.4 KiB
JSON
{
|
|
"name": "limitkit",
|
|
"version": "0.2.0",
|
|
"description": "Rate limiting as a decision, not a middleware: fixed and sliding windows over an injectable store, a bounded in-memory store, standard RateLimit headers, and client-IP extraction. No HTTP client, no framework.",
|
|
"license": "MIT",
|
|
"author": "Mao Nakamoto",
|
|
"homepage": "https://github.com/catomean/limitkit#readme",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/catomean/limitkit.git"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/catomean/limitkit/issues"
|
|
},
|
|
"keywords": [
|
|
"rate-limit",
|
|
"rate-limiting",
|
|
"sliding-window",
|
|
"fixed-window",
|
|
"throttle",
|
|
"headless"
|
|
],
|
|
"type": "module",
|
|
"sideEffects": false,
|
|
"engines": {
|
|
"node": ">=18"
|
|
},
|
|
"publishConfig": {
|
|
"access": "public",
|
|
"provenance": true
|
|
},
|
|
"files": [
|
|
"dist"
|
|
],
|
|
"exports": {
|
|
".": {
|
|
"types": "./dist/index.d.ts",
|
|
"default": "./dist/index.js"
|
|
}
|
|
},
|
|
"scripts": {
|
|
"build": "tsc -p tsconfig.json",
|
|
"lint": "eslint .",
|
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
"test": "node --test test/*.test.js",
|
|
"verify": "npm run lint && npm run typecheck && npm run build && npm test",
|
|
"prepare": "npm run build"
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/js": "^9.39.5",
|
|
"@types/node": "^22.10.2",
|
|
"eslint": "^9.39.5",
|
|
"globals": "^15.15.0",
|
|
"typescript": "^5.8.2",
|
|
"typescript-eslint": "^8.67.0"
|
|
}
|
|
}
|