Skip to content

P31: HTTP listener resource limits (sc serve --http) #38

Closed

Description

@tonibergholm

Phase spec from the 2026-07-09 security audit map (#24). Closes audit High #2 (thread/disk exhaustion on sc serve --http) — ADR-0036's three named operational boundaries plus the unbounded-spool gap the research surfaced. Zero new dependencies; PROTOCOL_VERSION stays 3.

Locked decisions

From Decide: HTTP listener resource limits (research: bounded-server patterns, docs/research/bounded-server-patterns.md):

  1. Connection limit — atomic count; at the limit, accept → immediate busy status at the HTTP opening (the 401/404 seam, before any wire handshake) → close. No queuing. Default 32, --max-connections <n>, 0 = unlimited. One total cap (no pre-auth sub-cap).
  2. Idle/progress deadline — read+write socket timeouts persist for the whole session (replace the clear at http_transport.rs:597-599; add set_write_timeout for the GetPack send side). Per-syscall timeout is progress-based under P25 chunking; timeout is connection-fatal (TempPackGuard cleans the spool on unwind). Handle WouldBlock (Unix) and TimedOut (Windows). On by default, 300s, --timeout <secs>, 0 = disable; opening keeps its 30s. Recorded divergence from git-daemon's off-default. Timeouts set on the TcpStream beneath any future TLS wrap (P32 compose point).
  3. Aggregate spool cap — counted mid-stream abort in the pack-stream readers (git receive.maxInputSize shape), typed error on the existing reply seam. Default 16 GiB (recorded divergence from git's unlimited), --max-pack-size <bytes>, 0 = unlimited; values < MAX_OBJECT_SIZE rejected as invalid config. Composes above ADR-0039's per-frame/per-record/decompression caps.
  4. Read-only drain cap — the drain-for-sync before EC_READONLY (wire.rs:678) drains at most 8 MiB; larger doomed pushes are dropped mid-send.
  5. Accept-loop backoff — Go's shape verbatim: 5ms doubling to 1s, reset on success; hardcoded, no knob, no reserved-fd trick.

Non-goals

Pre-auth connection sub-caps (sshd MaxStartups-style), reserved-fd shedding, client-side spool caps — all recorded as possible follow-ons, not this phase.

Acceptance criteria

  • Each bound has pinned regression tests (limit reached → busy status; stall → connection dropped + spool cleaned; oversized pack → typed error mid-stream + zero residue; accept-error backoff).
  • Existing demos stay green; extend or add a demo proving limit + timeout + spool-cap behavior with zero .sc/tmp residue.
  • ADR recording all four bounds, the two divergences-from-prior-art (timeout on-by-default, finite spool default), and the drain-cap posture.
  • docs/THREAT-MODEL.md: mark the three ADR-0036 boundaries closed, name and close the unbounded-spool gap, and carry the two audit-boundary re-affirmation wordings from env-var secret exposure (same-user adversary defeats the identity key; fd/stdin stays an additive deferred mode) and signature replay (ancestry is already id-bound; the residue is ref binding only — "replayable to a ref tip within its own history").
  • CLAUDE.md command docs updated for the three new flags.

Part of the #24 audit-response map.

Activity

  1. tonibergholm commented on Jul 10, 2026

    @tonibergholm
    MemberAuthor

    Shipped: PR #41 merged (all four bounds, ADR-0041, THREAT-MODEL closures + the #31/#32 re-affirmation wordings, demo/run_limits_demo.sh). Audit High #2 closed. Deferred follow-ons recorded in ADR-0041: 503-shed RST-race drain-before-close, demo pick_port TOCTOU sweep.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentTriage: ready for an agent to pick up

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions