Skip to content

fix(fleet-proxy): bound HttpConn response sizes, fail malformed Content-Length - #5587

Merged
dezren39 merged 1 commit into
mainfrom
queue/9671-5579-fleet-proxy-http-bounds
Nov 4, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/9671-5579-fleet-proxy-http-bounds

Conversation

@dezren39

@dezren39 dezren39 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Fixes #5579 (task 9671).

fleet-proxy's pooled HttpConn response reader trusted peer-declared sizes and misparsed malformed length headers:

  • Strict Content-Length: an unparsable value or duplicate headers with differing values are now HttpError::Malformed and mark the connection non-reusable, instead of silently reading as "no body" and desyncing the pooled connection. Agreeing duplicates are accepted.
  • Documented body cap pre-allocation: new MAX_RESPONSE_BODY_BYTES (64 MiB, matching fleet-proxy-proto's MAX_FRAME_BYTES ceiling) is enforced before any allocation sized by the declaration — on the Content-Length path (at header parse), on the chunked path (per chunk and cumulative), and on the close-delimited read_to_end path.
  • Bounded line reads: status, header, chunk-size, and trailer lines go through read_line_bounded (MAX_LINE_BYTES, 64 KiB, matching the tunnel CONNECT response cap precedent) instead of unbounded read_line.

Tests: 9 new canned-loopback pins in http.rs (invalid CL, conflicting duplicates, agreeing duplicates, oversize declared CL with no body sent, oversize chunk, cumulative-over-cap chunked, overlong status line, well-formed CL two-exchange reuse, well-formed chunked reuse).

Verification: cargo test -p fleet-proxy (pkgs/fleet workspace, laptop) — 22 passed, 0 failed.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of oversized or malformed HTTP responses. Responses exceeding supported size limits, containing overly long lines, or having invalid or conflicting length information are now rejected instead of being processed.
    • Valid responses using content-length or chunked encoding, including matching duplicate length values, continue to be accepted.

@dezren39
dezren39 requested a review from a team as a code owner November 4, 2026 16:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T16:58:27.269099Z d8d381e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The HTTP response reader now limits response body and line sizes. It rejects invalid or conflicting Content-Length values, oversized bodies, and overlong lines, and marks affected connections non-reusable. Loopback tests cover valid and malformed responses.

Changes: HTTP response bounds

Layer / File(s) Summary
Bounded response lines
pkgs/fleet/crates/fleet-proxy/src/http.rs
The reader adds 64 KiB line and 64 MiB body limits. Status and header lines use a bounded line reader.
Content-Length and close-delimited bodies
pkgs/fleet/crates/fleet-proxy/src/http.rs
The reader rejects invalid, conflicting, or oversized Content-Length values before allocation. Close-delimited bodies are limited to 64 MiB plus one detection byte.
Chunked body limits and regression tests
pkgs/fleet/crates/fleet-proxy/src/http.rs
Chunk-size and trailer lines use bounded reads. The reader checks chunk sizes against the cumulative body limit. Loopback tests cover valid responses and malformed or oversized inputs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Low · up to d8d38

The response limits are implemented, but signed Content-Length values remain accepted and several protections lack targeted regression coverage. These are bounded follow-ups rather than evidence of a serious runtime failure.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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

Labels

None yet

Projects

None yet

1 participant