fix(rpc): bound ingress authentication and replay sources
聽
TH
9m ago+715+715+012345678901234567890123456789-117-117-012345678901234567890123456789
Summary
A peer that reaches the daemon or proxy HTTP port controls /rpc input before it authenticates. This PR bounds that.
- Only an authenticated call registers a request ID.
- An unauthenticated caller holds a connection and body for at most 30 s (
DAEMON_RPC_PREAUTH_TIMEOUT_MS). - Each daemon and proxy holds at most 16 unauthenticated callers (
createRpcPreauthSlots). Another gets503, retryable reasonremote_preauth_busy, and a closed connection. Header-token callers skip the slots. - Replay bundle lookups read only own properties.
requireReplayPluginschecks bundle shape and size.
Before / after
- Before: the request ID registered before auth, so a peer could hold a tenant's ID and see
400 duplicate_request_id. After:lifetime.admitruns after every gate. - Before: no pre-auth deadline. After: at the deadline the daemon aborts the hook
signal, drops the body, and answers one401withConnection: closeafter earlier answers. The proxy answers401.
Validation
Hosted CI pending on 1296183afe. Local vitest: the 2 touched test files, packages/host-kit, and the proxy eager-closure budget pass. fallow audit is clean. No devices ran.
Production delta versus 0.22: +339 / -102 (net +237).
Residual risk: 16 bodies of up to 64 MiB for up to 30 s per host, with no aggregate byte accounting. A slot frees at the deadline while a hung auth hook may still be running.