http: bodies end at 64 KiB, and the checkout limit counts per IPv6 /48
Two limits that were not limiting. The listener's default body limit is 512 MiB and nothing set another, with no cap on connections: one 64 MiB POST took the server from 7 MB to 72 MB before the handler's own 16 KiB check answered 413. The limit is now 64 KiB. A request that announces more in Content-Length is answered 400 from its headers, with none of its body read: a 64 MiB upload is refused after 786 KB and the server's peak memory does not move. That is a limit on the decoded body, and the comment says so. A chunked request sent straight to the port can pad its chunk framing and still make one connection hold hundreds of megabytes; the parser that allows it is Crafter.Network's. Behind Caddy an oversized body is refused by request_body before it gets here, so this is one more thing that rests on port 8081 being private. The per-peer checkout limit was kept per address. Over IPv6 one subscriber holds a whole prefix, a /56 or a /48, and can submit from a fresh address every time, so the per-peer cap did nothing and the global cap was the only limit an IPv6 client met. The key is now the IPv4 address or the IPv6 /48 (RateLimitKeyFor). An IPv4-mapped address is keyed as the IPv4 client it is, and something that does not read as an address is keyed as written, so a peer is never dropped to "no peer" by its spelling. On a /56 ISP 256 neighbouring households share one budget of six submissions per ten minutes; that was weighed and taken. ShouldGuardRequestProvenance pins the key. ShouldServeRoutes drives it over HTTP: six addresses of one /48 are accepted, a seventh is refused with 429, the next /48 is not; and a body past 64 KiB is refused with the server still up afterwards. Found in the security review of 2026-11-26. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
f51105a768
commit
21d34b13ed
4 changed files with 312 additions and 3 deletions
|
|
@ -738,6 +738,32 @@ export namespace Catcrafts::Server {
|
|||
// limit rather than invent a peer.
|
||||
std::string_view ClientAddressFromForwarded(std::string_view forwarded);
|
||||
|
||||
// What a rate limit is kept under for the client at `address`: the
|
||||
// identity whose budget a submission is charged to.
|
||||
//
|
||||
// An IPv4 address is its own key. An IPv6 address is keyed by its /48,
|
||||
// written "2001:db8:1234::/48", because one IPv6 address is not one
|
||||
// client. A home line is handed a whole prefix (a /56 from most ISPs, a
|
||||
// /48 from some, RIPE's guidance being one or the other) and every
|
||||
// device on it picks addresses freely inside, so a limit kept per
|
||||
// address is no limit: a /56 is 2^72 of them. A /64 is not the boundary
|
||||
// either, a /56 holds 256. The /48 is the largest block a single
|
||||
// subscriber is normally given, so it is the smallest key that no one
|
||||
// subscriber can step out of.
|
||||
//
|
||||
// The price is that on a /56 ISP 256 neighbouring households share one
|
||||
// budget. For that to cost a real buyer anything, one of 255 neighbours
|
||||
// has to be flooding checkout in the same ten minutes, and what it costs
|
||||
// them then is "try again shortly". Weighed on 2026-11-26 and taken.
|
||||
// Phones and VPN exits share a /48 more widely, and already share one
|
||||
// IPv4 address, so nothing changes for them.
|
||||
//
|
||||
// An IPv4-mapped address (::ffff:203.0.113.7) is keyed as the IPv4
|
||||
// client it is. Anything that does not read as an address is keyed as
|
||||
// written, so a peer is never dropped to "no peer" by its spelling.
|
||||
// Empty in, empty out. Pure, and exported for the self-test.
|
||||
std::string RateLimitKeyFor(std::string_view address);
|
||||
|
||||
// Whether a state-changing POST may proceed, given its Origin header.
|
||||
//
|
||||
// A MISSING Origin is allowed: browsers have sent it on form POSTs for
|
||||
|
|
|
|||
Loading…
Reference in a new issue