Title: fleet-proxy(connect-udp): request-head bound is checked only after a whole line arrives — one newline-free line accumulates without limit · Issue #6511 · developing-today/code · GitHub
Open Graph Title: fleet-proxy(connect-udp): request-head bound is checked only after a whole line arrives — one newline-free line accumulates without limit · Issue #6511 · developing-today/code
X Title: fleet-proxy(connect-udp): request-head bound is checked only after a whole line arrives — one newline-free line accumulates without limit · Issue #6511 · developing-today/code
Description: fleet-proxy(connect-udp): request-head bound is checked only after a whole line arrives — one newline-free line accumulates without limit Summary The CONNECT-UDP endpoint's request-head reader claims a 64 KiB bound (MAX_HEAD_BYTES, "the ...
Open Graph Description: fleet-proxy(connect-udp): request-head bound is checked only after a whole line arrives — one newline-free line accumulates without limit Summary The CONNECT-UDP endpoint's request-head reader clai...
X Description: fleet-proxy(connect-udp): request-head bound is checked only after a whole line arrives — one newline-free line accumulates without limit Summary The CONNECT-UDP endpoint's request-head reader ...
Opengraph URL: https://github.com/developing-today/code/issues/6511
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fleet-proxy(connect-udp): request-head bound is checked only after a whole line arrives — one newline-free line accumulates without limit","articleBody":"# fleet-proxy(connect-udp): request-head bound is checked only after a whole line arrives — one newline-free line accumulates without limit\n\n## Summary\n\nThe CONNECT-UDP endpoint's request-head reader claims a 64 KiB bound\n(`MAX_HEAD_BYTES`, \"the bound exists so a peer cannot make the parser\naccumulate without limit\"), and the bound **is** enforced across many\ncomplete lines — but a single line with no `\\n` defeats it completely.\n`read_head_line` reads the entire line into memory first and only then\nchecks the cumulative total, so a peer streaming one newline-free line\nmakes the parser accumulate without limit for as long as it keeps\nsending. The sibling HTTP reader in the same crate does this correctly.\n\n## Evidence (origin/main `540d3bea3f`)\n\n`pkgs/fleet/crates/fleet-proxy/src/connect_udp.rs`:\n\n- `:76` — `pub const MAX_HEAD_BYTES: usize = 64 * 1024;` with the doc\n comment: \"the bound exists so a peer cannot make the parser\n accumulate without limit (peer-declared sizes are never trusted,\n #5579)\".\n- `:261-271` — `read_head_line`: `let n = reader.read_until(b'\\n', &mut line)?;`\n with **no limit applied to the read itself**; `*total += n` and the\n `*total > MAX_HEAD_BYTES` check happen only after `read_until`\n returns — i.e. after the whole line (however large) is already\n allocated in `line`.\n- `:284` — `read_request` reads the request line and every header line\n through `read_head_line`, so both the request line and any single\n header line are exploitable.\n- `:355` — `serve_session` sets a 250 ms read timeout (`RELAY_POLL`),\n but that only fires on an idle gap; a peer that keeps sending (the\n normal case for a flood) never trips it, and the session thread\n stays in `read_request` accumulating.\n\nContrast — the correct pattern in the same crate,\n`pkgs/fleet/crates/fleet-proxy/src/http.rs:143-155`:\n`read_line_bounded` wraps the reader in\n`.take((MAX_LINE_BYTES + 1) as u64).read_until(...)`, so allocation is\nbounded *during* the read and an over-long line errors as soon as it\ncrosses the cap.\n\n## Reproduction (verified this run)\n\nProbe `~/git/fleet/probe-udp-head` on the laptop (real `fleet-proxy`\ncrate via path dependency; `connect_udp.rs` identical at laptop HEAD\nand origin/main `540d3bea3f`), driving the public\n`connect_udp::serve` on a loopback listener:\n\n- **Valid control:** a well-formed CONNECT-UDP request to a loopback\n UDP echo target → `HTTP/1.1 200 OK` with `Capsule-Protocol: ?1`.\n- **Many-lines control:** valid request line + 100 header lines of\n ~1 KiB each → refused `HTTP/1.1 400` (\"request head exceeds the byte\n bound\") as soon as the cumulative total crossed 64 KiB. The bound\n works across lines.\n- **Single-line case:** request line prefix followed by **33,554,432\n bytes (32 MiB) with no newline**, streamed continuously in 64 KiB\n chunks: the server accepted every byte, sent **no response at any\n point during the stream**, and the process RSS grew\n **2,820 KiB → 35,716 KiB (Δ 32,896 KiB ≈ the full 32 MiB line)** —\n 512× the declared bound, held in the parser. Only after the probe\n finally sent `\\r\\n` did the server refuse with `400`\n (\"request head exceeds the byte bound\").\n\n`PROBE PASS` (all controls + the single-line case as described).\n\n## Why it matters\n\n`MAX_HEAD_BYTES` exists specifically so an untrusted peer cannot make\nthe parser accumulate without limit. As written, the limit is a\npost-hoc check, not a bound: any peer that can reach the CONNECT-UDP\nlistener (opt-in via `[proxy] connect_udp = true`, default loopback —\nbut the listener address is config-controlled) can grow one session\nthread's memory without limit with a single unterminated line, and\nthe 250 ms poll timeout does not save it because the flood keeps the\nsocket busy. Every session thread that is fed such a line is also\npinned in `read_request` for the duration. This is the #5579\npeer-trust class, in the one reader that checks after the fact\ninstead of during the read.\n\nDistinct from #6152 (no cap on the *number* of per-source CONNECT-UDP\nsessions in udp-forward) and from the http.rs repetition-count issue\nfiled earlier today (that reader caps each line during the read but\nnot how many lines/heads may repeat; this reader caps the total\nacross lines but not a single line during the read).\n\n## Acceptance criteria\n\n- [ ] `read_head_line` (or its replacement) bounds accumulation\n *during* the read — e.g. `take(remaining + 1)` in the style of\n `http.rs` `read_line_bounded`, or an equivalent chunked read —\n so a line is refused as soon as the cumulative head total would\n exceed `MAX_HEAD_BYTES`, without waiting for `\\n`/EOF.\n- [ ] A single line longer than the remaining head budget is refused\n with the same 400 shape as the many-lines case.\n- [ ] Loopback tests in `connect_udp.rs` pin: (a) one newline-free\n line streamed past `MAX_HEAD_BYTES` is refused promptly (not\n only after a newline is sent), (b) the many-lines overflow\n still refuses, (c) a valid request still returns 200.\n- [ ] Existing `fleet-proxy` tests keep passing\n (`cargo test -p fleet-proxy` on the laptop or CI).\n\n## Scope notes\n\n- Fix is local to `connect_udp.rs`'s head reader; the\n `UdpProxyClient` response-head reads reuse `read_head_line` and get\n the same fix for free.\n- Out of scope: session-count caps (#6152), capsule/datagram parsing\n after the head, `udp_forward.rs`.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-11-06T12:28:03Z","url":"https://github.com/developing-today/code/issues/6511"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:02792376-353b-2ae4-4eb8-1e3eed402b45 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B3B6:32CBBB:870C11:AFEE62:6B062EE1 |
| html-safe-nonce | e0dff19f7f7854b7cd78ef692183901a32a7ff5c10d053c49927c68c77257718 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0I2OjMyQ0JCQjo4NzBDMTE6QUZFRTYyOjZCMDYyRUUxIiwidmlzaXRvcl9pZCI6IjMzNDUyMjg3ODE3MjMyMDEyNDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7c4c63aa5b8b2963fbbc82b6c47383f58e72437251cd1fb03e58da2595ae3e08 |
| hovercard-subject-tag | issue:6242647689 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/6511/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6db23dd7f5258025461b5f0d19dcb0ad411589100b05cfd7e8a70463f2c444d7/developing-today/code/issues/6511 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6db23dd7f5258025461b5f0d19dcb0ad411589100b05cfd7e8a70463f2c444d7/developing-today/code/issues/6511 |
| og:image:alt | fleet-proxy(connect-udp): request-head bound is checked only after a whole line arrives — one newline-free line accumulates without limit Summary The CONNECT-UDP endpoint's request-head reader clai... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7f961de5dd5c5d4aca24d33f8b3ffb3fb8b2ef53d0a4f32f01f0a790e512f6d3 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 494ea0bb1e0feef734a83e2628697647755e8864 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width