Skip to content

Decide: HTTP listener resource limits (audit High #2) #28

Closed

Description

@tonibergholm

Part of #24

Question

Authenticated (or open-server) clients can hold one OS thread each indefinitely and exhaust disk via unbounded pack spooling; read-only clients reach the spool-before-reject path too (audit High #2). Which protections ship, with what defaults and what operator knobs: connection pool/limit, idle/progress deadlines, max transfer/spool size, accept-loop backoff? Resolution shapes a phase spec.

Activity

  1. self-assigned this
    on Jul 10, 2026
  2. tonibergholm commented on Jul 10, 2026

    @tonibergholm
    MemberAuthor

    Resolution

    All four bounds ship in one phase spec (none touches the wire protocol; PROTOCOL_VERSION stays 3). This closes ADR-0036's three named boundaries plus the fourth the research surfaced — the unbounded aggregate pack spool, reachable by read-only clients — updating ADR-0036/0040 and docs/THREAT-MODEL.md accordingly.

    Decisions:

    1. Connection limit — atomic count + busy-status-and-close. At the limit the server accepts, immediately writes a busy status at the HTTP opening (the seam where 401/404 already live, before any wire handshake), and closes; the client renders a clear retryable error. No queuing — for long-lived wire sessions, fail-fast beats invisible waits (rejected: block-at-accept semaphore, git-daemon's grace-then-shed). Default 32 (git-daemon's shipped default; sc ws run agents pushing in parallel are legitimate concurrency), --max-connections <n>, 0 = unlimited. One total cap; an sshd MaxStartups-style pre-auth sub-cap is deliberately deferred until real churn proves the need.
    2. Idle/progress deadline — on by default, 300s. Read+write timeouts persist for the whole session (replacing today's clear at http_transport.rs:597-599; a write timeout also covers a client that stops reading mid-GetPack). Under P25 chunking a per-syscall timeout IS progress-based — only true zero-byte stalls trip it — and timeout is connection-fatal (frame desync precludes recovery; TempPackGuard cleans the spool on unwind). --timeout <secs>, 0 = disable; opening keeps its existing 30s. Shipping on-by-default is a recorded divergence from git-daemon's off-default: defaults-off knobs don't close audit Highs, and without a reaper the connection cap is hostage to any single stalled client. 300s (not 60s) because the one legitimate casualty is a client computing between verbs. Compose point with Decide: transport confidentiality for sc+http (audit High #1) #26: timeouts are set on the TcpStream beneath the future rustls wrap.
    3. Aggregate spool cap — 16 GiB default. Counted mid-stream abort in the pack-stream readers (git receive.maxInputSize shape), surfacing as a typed error on the existing reply seam. Finite default is a recorded divergence from git's unlimited: sc servers often share the working tree's volume, and this effort's posture is fail-closed defaults throughout. --max-pack-size <bytes> serve flag (no .sc/config surface exists yet), 0 = unlimited; configured values below MAX_OBJECT_SIZE (256 MiB) are rejected as invalid config. Composes above, never replaces, ADR-0039's per-frame/per-record/decompression caps.
    4. Read-only drain — capped at 8 MiB. The deliberate drain-for-sync before EC_READONLY (wire.rs:678) now drains at most ~8 MiB: an honest ro-token pusher still gets the clean typed error for any small push; anything larger is dropped mid-send and spools nothing more.
    5. Accept backoff — Go's exact shape, hardcoded. 5ms doubling to 1s, reset on success, around the accept loop; no knob (Go ships it knobless), no reserved-fd shed (the connection cap demotes fd exhaustion to external pressure; the refinement can ride a later hardening pass if ever needed).

    Research basis: Research: std-only bounded-server patterns for the HTTP listener → docs/research/bounded-server-patterns.md (PR #36).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

wayfinder:grillingWayfinder ticket: HITL grilling/decision

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions