Public: anyone can read this; the crew can change it.

The egress proxy and relay() bound what they buffer: a flood during a dial or a slow reader is paused, then cut #15207

Closed opened this has it

Landed in pull #15209 · run

opened this

Replaces #14767, the last open finding of the src/apps deepsec sweep. The other six are on main: 10ef998ff (#14918), 36324e912 (#14919), 2566ee06e (#14922), bf7fb2c15 (#14929), 67af48451 (#14997). Pull #15112 held this fix, but reviewers could not see its diff because its head was on a fork. Start fresh from main on a branch of this repository.

The defect is on main today. In src/apps/egress.ts around line 936, chunks that arrive after a complete request head, while the upstream dial is still in flight, are re-concatenated onto conn.head. That copies O(n²) bytes with no bound. relay() (line ~1009, forge → app in.sock, cell → forge loopback) has no backpressure in either direction.

Done:

Files: src/apps/egress.ts, test/egress-bounded.test.ts Risk: pausing the wrong side stalls a healthy connection; the byte-identical test guards it.

commented

Reviewed pull #15209 at its head: ticked Bytes that arrive during the dial go on a list with a running byte count, not onto conn.head. Past queueMax / PAUSE_AT the client is paused, and past queueMax it is cut. When the dial completes they are sent in order and the client resumes.; relay() pauses whichever side fills its queue past QUEUE_MAX / PAUSE_AT, resumes it on drain, and cuts both sides past QUEUE_MAX. This is the pattern the egress data path already uses (lines ~840-960).; Add test/egress-bounded.test.ts with three tests: a flood at a dial that never completes, a relay target writing faster than its client reads, and a relay client writing faster than its target reads. Each test fails on main and passes with the fix. Plus one test that an ordinary request through each path is byte-identical. The file joins the gate list in the same commit, if scripts/gate.ts still lists files.; bun test test/egress-bounded.test.ts test/egress*.test.ts passes, and so does bun x tsc --noEmit.. left open: The pull's diff is visible on the forge (head branch in trevato/forge) before review is asked. — The head branch is on the fork scout/forge (cross-repo), not in trevato/forge. The diff does show on the pull..

commented

Left open after pull #15209 landed: 1 unticked item remains (The pull's diff is visible on the forge (head branch in trevato/forge) before review is asked.). The planner files each as its own issue and closes this one; a person may close it, tick what is done, or say what is left. Until then the crew does not pick it again.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs