Skip to content

fleet-dispatch accepts invalid or truncated HTTP response framing #8433

Closed

Description

@dezren39

Evidence

Read-only Phase 4 inventory for #6583, main 9b82fb905929042aa5244835bc0e4a5d370d1daf: pkgs/fleet/crates/fleet-dispatch/src/lib.rs:246-259 silently treats malformed Content-Length as absent, overwrites duplicates and accepts Transfer-Encoding containing chunked; :273-292 treats EOF as success even when a declared length or chunked stream is incomplete and returns a partial body. dechunk at :327-346 also tolerates missing chunk terminators. A partial body can be valid JSON, making the truncation silent. This conflicts with #6582’s present-but-invalid refusal contract.

Acceptance

  • Define and enforce unambiguous framing and reject malformed/conflicting Content-Length and incomplete declared/chunked bodies with the transport error shape.
  • Add loopback regression tests including invalid and duplicate lengths, truncation after valid JSON bytes, malformed/truncated chunks and valid controls; test oracle is the framing contract.
  • Respect the response body bound and check all arithmetic before allocation.

Related #6583, #6582; no code was modified in the inventory.

Activity

  1. developing-today commented on Nov 11, 2026

    @developing-today
    Contributor
  2. added
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 11, 2026
  3. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    task_id: 14827
    worker: repo-worker-code
    lane: code-h
    state: triaged
    KIND: triage (inline, task 14827) — small_fix, priority/normal, effort/s, kind/bug; fix proceeding in this same claim

    Triage decision:

    • Work kind: task/small-fix — a bounded correctness fix in one crate (pkgs/fleet/crates/fleet-dispatch), with loopback regression tests; the issue's acceptance names the test oracle (the framing contract).
    • Priority: priority/normal — fleet-internal transport integrity (silent truncation can pass off a partial body as a complete response), but no live outage; band-10 is reserved for fleet-stalling breakage per the priorities brief.
    • Effort: effort/s — one function cluster (read_response + chunk helpers in src/lib.rs) plus tests.
    • Labels applied: task/small-fix, priority/normal, effort/s, kind/bug (plus queue/work lifecycle labels).

    Fresh verification of the evidence (current main, 2026-11-11): pkgs/fleet/crates/fleet-dispatch/src/lib.rs still shows every cited defect — Content-Length parsed with value.parse().ok() (malformed silently treated as absent, duplicates overwrite), Transfer-Encoding accepted on a contains("chunked") test, the body loop breaks on EOF and then truncates to whatever arrived (body[..n.min(body.len())] / lenient dechunk), and dechunk tolerates a missing chunk terminator. This conflicts with #6582's present-but-invalid refusal contract, as the issue states.

    First concrete step (underway in this claim): strict framing in read_response — refuse malformed/conflicting Content-Length, refuse Content-Length + Transfer-Encoding together and non-final/unsupported transfer codings, treat EOF before a declared length or before a complete chunked stream as a transport error, and make chunk decoding verify terminators — with loopback regression tests for each case plus valid controls.

    Acceptance check for the fix: the issue's three bullets — unambiguous framing enforced with the transport error shape; loopback tests covering invalid and duplicate lengths, truncation after valid JSON bytes, malformed/truncated chunks, and valid controls; body bound respected and all arithmetic checked before allocation (the #6512 discipline already present in dechunked_len is preserved).

  4. added a commit that references this issue on Nov 11, 2026
  5. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    task_id: 14827
    worker: repo-worker-code
    lane: code-h
    state: done
    KIND: small_fix — strict response framing landed via PR #8434 (merge 63ee781); this issue is closed

    What changed in pkgs/fleet/crates/fleet-dispatch/src/lib.rs (+252/−61):

    • Content-Length: every statement (repeated headers, comma-joined values) must parse and all must agree; malformed or conflicting values are transport errors instead of silently absent/overwritten.
    • Transfer-Encoding: accepted only as the single coding chunked; Content-Length + Transfer-Encoding together are refused as conflicting framing; any other coding (including gzip, chunked) is refused as unsupported.
    • Body reads track an explicit framing: EOF before a declared length, or anywhere inside a chunked stream including its trailer section, is now a truncation transport error — a partial body is never returned as complete. Unframed bodies still run to connection close.
    • Chunks decode through one strict parser that separates complete / incomplete / malformed: non-hex size lines and chunks missing their CRLF terminator are errors. The fleet(dispatch): dechunked_len does unchecked arithmetic on the peer-declared chunk size — overflow panics in debug, wraps in release #6512 checked-arithmetic discipline and the 64 MiB bound are preserved.

    Verification: cargo test -p fleet-dispatch — 16 passed, 0 failed, including 5 new loopback regression tests (valid round-trips for length/chunked-with-trailer/agreeing-duplicate/unframed bodies; refusal of malformed/conflicting/CL+TE framings; truncation after valid JSON bytes; malformed chunk size; missing CRLF terminator). cargo fmt applied. Test oracle is the framing contract, per the issue's acceptance.

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

    effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)status:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions