GeezerVison is showing github.com — id(web/world): snapshot/event sequence and participant ids accept negative, fractional and unsafe numbers — a malformed frame poisons the reconnect cursor (PR #4236 residual) · Issue #10401 · developing-today/code
id(web/world): snapshot/event sequence and participant ids accept negative, fractional and unsafe numbers — a malformed frame poisons the reconnect cursor (PR #4236 residual) #10401DescriptionFinding
PR #4236 added shape validation for world WebSocket snapshot/event frames in the web client, but the numeric fields are checked only for finiteness: current_sequence, event sequence, and participant id accept negative, fractional, and unsafe-integer values (e.g. -1, 1.5, 1e100). Those values are world-protocol u64s — the shell contract in the same repo bounds sequence as a u64 (see the #4238 tests) and PR #4250's collab validator requires Number.isSafeInteger(version) && version >= 0 for the analogous field — so a frame the Rust server could never legitimately send passes the web validator and poisons client state:
pkgs/id/web/src/world.ts (current main, fb124d8): isFiniteNumber at line 159; isWorldSnapshot (160–169) checks current_sequence and participant id with it; isWorldEvent (170–186) checks sequence and participant_id with it.
- A snapshot with
current_sequence: -1 (or 1.5) is accepted and assigned straight to the reconnect cursor (line 225: cursor = snapshot.current_sequence). On reconnect the join frame sends after: cursor || null (line 568) — a negative or fractional cursor goes on the wire verbatim as the resume position.
- An event with
sequence: 1e100 is accepted and cursor = Math.max(cursor, event.sequence) (line 245) raises the cursor past every real sequence: after a reconnect the client asks to resume after 1e+100, i.e. past the end of the world log.
- A fractional
participant_id never matches a rendered participant ([data-participant="1.5"]), so chat lines fall back to a bogus player 1.5 identity instead of the frame being rejected.
This is the same shape-trust class the repo has been closing frame-by-frame (#7908 records cursor, #7924 view/error frames, #7928 upload/compile fields, and #4250's INIT version check) — the snapshot/event numeric fields are the remaining gap in the validator #4236 introduced.
Evidence
- Source PR: fix(id-web): validate world snapshot and event frames #4236 — fix(id-web): validate world snapshot and event frames #4236 (merge commit
ee5f0d4f253a6e2069891e37d044a280424ca19a, confirmed ancestor of current main, compare status ahead). It implemented the Phase-3 fix for id(web): world WebSocket receive() trusts frame shape past the type tag — a parseable-but-wrong-shaped snapshot/event throws out of the handler and is dropped mid-processing #2802 (CLOSED) by adding isWorldSnapshot/isWorldEvent with isFiniteNumber checks; its tests cover missing/wrong-type/NaN fields but no negative, fractional, or >2^53 values.
- Current main
fb124d87f7c01523499635dfc4910dab92ad9f79, pkgs/id/web/src/world.ts lines 159–186, 225, 245, 568 — read directly from main this run; the validators are unchanged since fix(id-web): validate world snapshot and event frames #4236 apart from later sibling-frame checks (id(web/world): session-WS records frame shape-trusted — a string records renders per-character entries, a non-string next_after is echoed back as the pagination cursor #7908/id(web/world): session-WS invite, view and error frames shape-trusted — a non-string invite capability is persisted as '[object Object]', non-string view/error text renders coerced #7924) that did not touch these fields.
- Contrast in the same batch: PR fix(id-web): validate collaboration MessagePack frames #4250 (
pkgs/id/web/src/collab.ts) rejects an INIT version unless Number.isSafeInteger(version) && version >= 0; PR fix(id-web): validate shell contract field specs #4238's shell-contract validator enforces u64 bounds on sequence.
Why it matters
The validator's job (#2802) is that a parseable-but-wrong-shaped frame changes no state. Today a single malformed snapshot or event silently moves the resume cursor to a position the server never issued — negative, fractional, or past the end of the log — and the damage only appears later, at reconnect, as a join the server cannot honor or a resume that skips the world's history. Rejecting the frame at receipt (the established rejectFrame() discipline) keeps the failure visible and the cursor trustworthy.
Acceptance criteria
isWorldSnapshot/isWorldEvent reject negative, fractional, and unsafe-integer (>2^53) values for current_sequence, sequence, participant_id, and participant id — e.g. a shared safe-non-negative-integer check mirroring fix(id-web): validate collaboration MessagePack frames #4250's INIT version rule — with the frame rejected via the existing rejectFrame() path and no cursor/DOM state change.
- Regression tests in the world-records/world validator suite deliver snapshot/event frames with
-1, 1.5, and 1e100 sequence values (and a fractional participant id) and pin rejection plus an unchanged cursor (a subsequent reconnect join still sends the pre-frame after).
- Valid frames at the u64-representable boundary the existing tests use (e.g.
2 ** 53 sequences in the shell-contract suite) keep their current accepted behavior where the contract allows it — no tightening beyond the wire type.
Found by pr-diff-review lane B reviewing PR #4236 against current main. Dedupe: issue searches (isWorldSnapshot, current_sequence, world snapshot sequence negative) returned the sibling shape-trust issues (#7831 open — host-view/invite HTTP responses; #7908, #7924, #7928 closed — records/view/invite/upload frames) and #2802 (closed, the parent #4236 implemented); none covers snapshot/event sequence or participant-id integrality. Activitydeveloping-today commented on Nov 14, 2026 dezren39 commented on Nov 14, 2026 agent-note:v1
Agent: pr-diff-review-b
State: filed
Repo: developing-today/code
Source PR: #4236 (#4236, merged ee5f0d4); implements fix for #2802 (CLOSED)
Finding: PR #4236's world web validators check snapshot/event numeric fields only for finiteness (pkgs/id/web/src/world.ts:159-186 on main): current_sequence, sequence and participant ids accept -1, 1.5 and 1e100, though they are protocol u64s; an accepted snapshot assigns the value to the reconnect cursor (:225, sent as join after at :568) and an event raises it via Math.max (:245), poisoning resume.
Verified against main: fb124d8 (contents read of world.ts on main; PR #4236 merge confirmed ancestor, compare ahead). Contrast: PR #4250's collab INIT version requires Number.isSafeInteger && >= 0; PR #4238's shell contract bounds sequence as u64.
Evidence: hidden_files/pr-review-b-2026-11-14-1718-code/issue-4236-sequence-body.md + diff-4236.patch + main-world.ts dezren39 commented on Nov 14, 2026
Agent note — picked up + triaged (task 17335, lane code-d)
- State: triaged — claimed by lane code-d (queue task 17335); inline triage per runbook §1c, fix proceeds in the same session.
- Work kind: small-fix (
task/small-fix). Priority: priority/low (kept) — validation-consistency gap on a server-supplied frame path; legitimate server never sends such values, trigger is a faulty/hostile endpoint.
- Effort:
effort/xs — one shared safe-non-negative-integer check in pkgs/id/web/src/world.ts plus regression tests.
- First concrete step: verify current
world.ts validators on fresh main, add a shared isSafeNonNegativeInteger check mirroring PR fix(id-web): validate collaboration MessagePack frames #4250's collab INIT rule for current_sequence, sequence, participant_id, and participant id, routed through the existing rejectFrame() path.
- Acceptance check: regression tests deliver
-1, 1.5, and 1e100 sequence frames and a fractional participant id, pinning rejection and an unchanged reconnect cursor; existing pkgs/id/web suites keep passing with no tightening beyond the wire type.
dezren39 commented on Nov 14, 2026
Agent note — done (task 17335, lane code-d)
dezren39 commented on Nov 14, 2026
Agent note — duplicate fix packet already done (task 17338, lane code-d)
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|