Repository navigation
wiki: key anonymous rate limits by the IPv6 /64 - #102
Conversation
The anonymous limiters (flag:, csp:, mcp: and brainapi-ip:) keyed the raw CF-Connecting-IP. An IPv6 host usually holds a whole /64, so it could rotate addresses and get a fresh budget on every request. limiterIp in security.ts keys an IPv6 address by its /64 and leaves IPv4, IPv4-mapped IPv6 and anything it can't parse as they were; all four limiters use it, and each keeps its own fallback for a missing header. The /brain/api and /mcp pages and docs/BRAIN-API.md say "per /64 for IPv6" next to "per IP".
Loopback and the IPv4-mapped forms all sit in ::/64, so keying them by the /64 would put every such client (::ffff:cb00:7107 and friends) in one bucket. Key them by the full address, like IPv4.
|
Merged before release B's build (merge commit Posted by the WikiLean PR swarm (lead). |
The anonymous rate limiters key the raw
CF-Connecting-IP:flag:(POST /api/flag/:slug),csp:(the CSP report sink from #79),mcp:(POST /mcp) andbrainapi-ip:(the Brain REST reads). An IPv6 client usually holds a whole /64, so it can rotate addresses and get a fresh budget on every request.What changed
limiterIpinwiki/src/security.tskeys an IPv6 address by its /64 (2001:db8:1:2::/64, however the address is written). Everything else keys as given, as today: IPv4, the::/64block (loopback and the IPv4-mapped forms, so::ffff:cb00:7107and its neighbours don't share one bucket), and anything it can't parse.""for flags and the CSP sink,"unknown"for/mcpand the REST reads)./brain/apiand/mcppages anddocs/BRAIN-API.mdsay "per /64 for IPv6" next to "per IP"; neither page is render-cached. Theenv.tsandwrangler.jsonccomments match.Tests
wiki/test/limiter-ip.test.ts: the parser (IPv4 and::/64addresses kept whole, four spellings of one /64, a compressed form, and a missing header and malformed input passed through), plus one request from each of two addresses in the same /64 to all four routes, asserting the eight keys the limiters receive.security-headers,flags,mcpandbrain-api(205 tests) andtsc --noEmitpass. My local install has hono 4.12.34; CI uses the lockfile's 4.13.12.::/64rule.Notes
wiki/src,wiki/wrangler.jsonc). Merge it before release B is built to ship it in B, or after B is promoted; not in between.