Repository navigation
fix(fleet-proxy): bound connect_udp read_head_line accumulation during the read (#6511) - #6522
Conversation
…g the read read_head_line read a whole line into memory before checking the cumulative MAX_HEAD_BYTES total, so one newline-free line accumulated without limit (#6511). Bound the read itself with take(remaining + 1), mirroring http.rs read_line_bounded but against the cumulative head budget: a line is refused with the existing InvalidData error as soon as the total would cross MAX_HEAD_BYTES, while a line exactly filling the remaining budget still succeeds. The UdpProxyClient response-head reads reuse read_head_line and get the same fix. Regression tests pin: a single over-bound line is refused with accumulation capped at bound+1, the bound is cumulative across lines, a line exactly at the bound still reads with a clean EOF after it, and read_request surfaces the refusal as a 400.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 5 minutes. View limit details
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. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Fixes #6511
Problem
read_head_lineinpkgs/fleet/crates/fleet-proxy/src/connect_udp.rsread a whole line into memory withread_untiland only then checked the cumulativeMAX_HEAD_BYTES(64 KiB) total — so one newline-free line accumulated without limit for as long as a peer kept sending, defeating the bound that exists so a peer cannot make the parser accumulate without limit.Fix (route decided in triage task 11123)
Bound the read itself:
read_head_linenow wraps the reader intake(remaining + 1), whereremaining = MAX_HEAD_BYTES - *total(the connect-udp bound is cumulative across the whole head, unlike http.rs's per-line cap inread_line_bounded, whose shape this mirrors). A line is refused with the existingInvalidData"request head exceeds the byte bound" error as soon as the cumulative total would crossMAX_HEAD_BYTES, without waiting for a newline; the +1 lets a line that exactly fills the remaining budget still succeed. TheUdpProxyClientresponse-head reads reuseread_head_lineand get the same fix for free.No changes to session-count caps (#6152), capsule/datagram parsing,
udp_forward.rs, orhttp.rs.Tests
cargo test -p fleet-proxyon the laptop: 60 lib + 14 bin tests pass, including 4 new regression tests inconnect_udp::tests:head_line_bound_applies_during_the_read— a single over-bound newline-free line is refused with reader consumption and accounting both capped at bound + 1head_line_bound_is_cumulative_across_lines— a second line gets only the remaining budgethead_line_exactly_at_the_bound_still_reads— a line exactly filling the budget succeeds; clean EOF at the bound isOk(None)request_head_over_bound_single_line_is_a_400— the refusal surfaces as the existing 400 shapecargo fmt -p fleet-proxy -- --checkclean. (Laptop clippy is blocked by a pre-existing toolchain-version skew in thefleet-configbuild cache, unrelated to this change; CI clippy is authoritative.)Queue: task 11162 (repo-health-code-pilot), lane code-v.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.