fix(relay): one address or network cannot stop the relay for the others
A review found ways for one cheap attacker to stop the service. - Line handshakes were limited only by a global pool: one address could finish a hello, stall, and repeat. A handshake now holds a place for its address (4) and network (64) from the relay's host name to the verdict. - Claims were counted per full address and against the certificate authority's weekly 50: one IPv6 /64 could spend all 50 with throwaway keys. Addresses now count by IPv6 /64 and /48 and IPv4 address and /24; claiming a name is limited by a separate safety ceiling (5 000 a day) and by those prefix limits, and the authority's weekly budget is charged when a name first publishes a proof record (once per name, renewals free, durable in the registry), under per-prefix limits of its own. - IPv4 callers on a dual-stack listener (::ffff:a.b.c.d) shared one slot: every table now makes the address canonical first. - The pool of unfinished hellos also counts per /48 and /24, and a reserve is kept for addresses that held a proven line lately (the server name is not known before the hello, so it is for who calls, not what is asked). - A static account-binding secret was served to anyone with a name: the list file may no longer carry one (refused at load), a binding comes only from a per-app source, and an authority that needs one and has none is served without and marked not usable. - Blocking now reaches a live line: the next publish and a sweep every 10 s close it. - Unclaimed, held-by-another-key and blocked names answer a stranger the same. - A hostile app and caller could make a line hold 13 MiB: yamux fixes each stream's window at 256 KiB, so the stream limits are 8+2+4 (3.5 MiB), and the splice has a minimum rate in place of a per-write stall check. - DNS answers truncated over the per-address rate, has a global ceiling, answers CAA from the authority list (issue per authority, dns-01 only), and passes over a Windows UDP connection reset without sleeping. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
8988769015
commit
13adeac382
14 files changed
+1920
-294
No files matched your search
+13
-5
@@ -18,7 +18,13 @@
|
||||
//! side, is ended (that is yamux's rule), so the relay keeps its
|
||||
//! own per-line permits below the limit.
|
||||
//! 2. Each stream's receive window is 256 KiB and a line's windows sum
|
||||
//! to at most 256 KiB times `max_streams`: no window grows.
|
||||
//! to at most 256 KiB times `max_streams`: no window grows. The size
|
||||
//! is yamux's own constant (the specification's initial credit; the
|
||||
//! 0.14 crate offers no way to start a stream with less), so what a
|
||||
//! line can be made to hold, by an app whose own caller reads slowly,
|
||||
//! is set by how many streams it may have, which is why the relay's
|
||||
//! stream limits are small. The splice's minimum rate bounds how long
|
||||
//! a stream can stay full.
|
||||
//! 3. A line from which nothing was read for `idle` is closed.
|
||||
//! 4. Dropping every handle, or `close`, ends the driver.
|
||||
//! SCENARIOS:
|
||||
@@ -79,10 +85,12 @@ pub struct MuxLimits {
|
||||
fn yamux_config(max_streams: usize) -> Config {
|
||||
let mut cfg = Config::default();
|
||||
cfg.set_max_num_streams(max_streams);
|
||||
// 256 KiB is yamux's initial window per stream. Capping the sum at
|
||||
// 256 KiB times the stream limit stops the auto-tuning from growing
|
||||
// any window: this is the most a line can ever hold in receive
|
||||
// buffers.
|
||||
// 256 KiB is yamux's initial window per stream, and the crate fixes
|
||||
// it (`DEFAULT_CREDIT`; the connection's cap must be at least that
|
||||
// times the stream limit, or it panics). Capping the sum at exactly
|
||||
// that stops the auto-tuning from growing any window: this is the
|
||||
// most a line can ever hold in receive buffers, and the only lever
|
||||
// left on it is `max_streams`.
|
||||
cfg.set_max_connection_receive_window(Some(max_streams * yamux::DEFAULT_CREDIT as usize));
|
||||
cfg
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user