You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
id(range-sync): frames() never validates an entry's upper-bound length — bounds over KEY_LEN encode into frames decode_frame itself rejects, ≥256 wraps the u8 length prefix and garbles the entry, and check_bounds approves them all #2595
The range-sync encoder never checks an entry's upper-bound length against the key length, so it happily emits frames that the crate's own decoder refuses — and past 255 bytes the one-byte length prefix wraps and garbles the entry stream.
Evidence (pkgs/id/src/event_store/range.rs, main 3a42555):
Wire format (module doc, lines 19–24): an entry's upper bound is "one length byte, 0 for +infinity, then the prefix", and a bound is a prefix of a sync key — at most KEY_LEN = 72 bytes (line 35).
encode_entry (line 415) writes the length as out.push(b.len() as u8) with no validation. frames() (lines ~446–465) checks only that the encoded entry fits the frame budget — never the bound length.
The decoder enforces the limit the encoder ignores: Reader::entry rejects len > KEY_LEN with "a bound of {len} bytes is longer than a key".
check_bounds (lines ~571–590) — the documented pre-flight check that Party::respond requires callers to have run on a message — checks only that bounds increase and that nothing follows +infinity. It does not check bound length either, so it approves every case below.
Verified this run (laptop probe, real crate, main 3a42555)
Probe: ~/git/fleet/probe-2026-10-30-laneA-rangeenc/ (id path dependency, default-features off; one Entry { upper: Some(vec![0xAA; N]), mode: Skip } per case):
N=72: frames() OK, decode_frame round-trips equal. check_bounds Ok.
N=100: frames() OK, decode_frame ERR "a bound of 100 bytes is longer than a key". check_bounds Ok.
N=255: frames() OK, decode_frame ERR (same). check_bounds Ok.
N=256: frames() OK, decode_frame ERR "unknown mode byte 170" — the length byte wrapped to 0 (+infinity) and the decoder started reading the bound's own bytes as the mode byte; the frame's remaining bytes are garbage. With different bound bytes the wrapped prefix can parse as a different, valid-looking entry instead of erroring. check_bounds Ok.
N=300: frames() OK, decode_frame ERR "unknown mode byte 170" (300 wraps to 44, then the stream desynchronises). check_bounds Ok.
Internal producers are safe today only by construction: separators are at most KEY_LEN bytes and inbound entries pass through decode_frame. But Entry, frames, check_bounds and Party::respond are the public library surface of /id-range-sync/1, and respond() clones the upper bounds of the caller's message into its answer — any caller that builds or forwards a message without going through decode_frame (exactly the callers check_bounds exists for) can produce an undecodable or silently re-interpreted flight and kill the session with errors that point at the wrong layer ("unknown mode byte").
Why it matters
A sender-side length bug should fail at the sender, with its own name on it. Today it surfaces on the peer (or the same process one step later) as a framing/mode error, and at ≥256 bytes the length-prefix wrap means the byte stream no longer means what the sender wrote. Fail-closed at encode time is the same pattern this module already uses for frame budgets ("an entry of {} bytes does not fit a {}-byte frame").
Acceptance criteria
frames() (or encode_entry) refuses an entry whose upper bound is longer than KEY_LEN, with an error naming the bound length and the 72-byte key limit.
check_bounds also refuses an over-length bound, so the documented pre-flight check catches what respond() would otherwise clone into its answer.
Tests cover bound lengths 72 (accepted, round-trips), 73/100/255 (refused at encode), and 256/300 (refused at encode — no wrap), plus check_bounds refusing an over-length bound.
Session / ID: new-issue-creator-code-a cron run 2026-10-30 01:05 CDT
Found via: filed this run
Task: Filed: range-sync frames()/encode_entry never validates an entry upper-bound length against KEY_LEN (72) — bounds of 73–255 encode into frames decode_frame itself rejects, ≥256 wraps the u8 length prefix and garbles the entry stream, and check_bounds (the documented pre-flight for respond) approves them all. Verified with a laptop probe against the real crate at main 3a42555.
Expectation: effort xs; done when frames()/encode_entry and check_bounds refuse an over-length bound with an error naming the limit, with tests at 72/73/255/256.
Task: PR id(range-sync): refuse entry upper bounds over KEY_LEN at frames() and check_bounds (#2595) #3462 opened @ 751bc3026 implementing the pinned gate (shared check_bound_len in frames() + check_bounds(); tests for 72/73/100/255/256/300). Parked because verification is still running: cargo test --lib event_store::range on the laptop (worktree ~/git/fleet/5390-2595-range-bound, log /tmp/test5390.log on the laptop) is compiling under load ~124 — the id crate's own compile had not started when this shift's budget ran out.
Activity
dezren39 commentedon Oct 30, 2026
🤖 Agent note · filed
6 remaining items
dezren39 commentedon Nov 1, 2026
🤖 Agent note · parked
751bc3026implementing the pinned gate (sharedcheck_bound_lenin frames() + check_bounds(); tests for 72/73/100/255/256/300). Parked because verification is still running:cargo test --lib event_store::rangeon the laptop (worktree~/git/fleet/5390-2595-range-bound, log/tmp/test5390.logon the laptop) is compiling under load ~124 — the id crate's own compile had not started when this shift's budget ran out.dezren39 commentedon Nov 1, 2026
🤖 Agent note · picked up
Merge pull request #3462 from developing-today/queue/5390-2595-range-…
dezren39 commentedon Nov 1, 2026
🤖 Agent note · done