Repository navigation
Description
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
Summary
On the world page, three of the remaining session-WebSocket frame handlers in
pkgs/id/web/src/world.ts receive() trust the frame's shape, unlike their
sibling handlers in the same switch. A wrong-shape frame from the server
(stale/buggy host, middlebox, or a future server change) is not rejected: a
non-string invite capability is adopted, coerced, and persisted to
sessionStorage as the session capability, and non-string view data /
error messages are rendered as their coerced string form
('[object Object]') instead of the frame being rejected.
Evidence (verified on main @ 30bd3a1; world.ts unchanged from a97c23c)
pkgs/id/web/src/world.ts:
- The frame is accepted with a bare cast —
const frame = parsed as WorldFrame;
(receive(), ~line 199) — with the declared contractinvite?: { capability?: string; … },
data?: string,view_revision?: number,message?: string(~lines 24–44). - Sibling cases validate before use:
snapshotis checked with
isWorldSnapshot,eventwithisWorldEvent, and therecordscase was
filed separately as 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; failures go torejectFrame(). The upload
socket in the same file validateschunk_bytes(integer, 1..6144) before use. - The
invitecase (~lines 297–305) has no equivalent guard:
const invite = frame.invite ?? frame; if (invite.capability) { showCapability(invite.capability); … }
— any truthy value is passed toshowCapability(~lines 180–185), which does
capability.value = value; sessionStorage.setItem(storageKey, value);and
unhides the invite output. An object capability is stored as the literal
string'[object Object]', a numeric one as'12345', and the status still
reports “Invite ready to share” — the bogus value is then the capability the
page rehydrates from sessionStorage and offers to copy/share. - The
viewcase (~lines 237–266): thesurfacepath is guarded by
renderWorldSurface, and thepatchpath checks
typeof frame.view_revision === "number", but the fallback
if (frame.data !== undefined) { view.textContent = frame.data; renderedViewRevision = frame.view_revision ?? null; }
accepts any type: an objectdatarenders as'[object Object]', and a
non-numberview_revisionis stored verbatim as the rendered revision,
after which patch base-revision comparisons can never match it. - The
errorcase (~lines 306–310):setStatus(frame.message ?? "World request failed", "error")
and the log line accept any type; an object message is displayed as
'[object Object]'instead of a real error or a rejected frame.
Reproduction (probe on the laptop, ~/git/fleet/probe-world-frames-20261108,
real world.ts driven through the same FakeWebSocket harness as
world-records.test.ts; probe copy byte-identical to main; 6/6 probe tests
pass — the malformed cases assert the current wrong behavior — and the
baseline world-records.test.ts suite is 6/6 green):
- Control:
{type:"invite", invite:{capability:"cap-valid-123", display_name:"bob"}}
→ sessionStorage storescap-valid-123, status “Invite ready to share”. ✔ {type:"invite", invite:{capability:{forged:true}, display_name:"bob"}}
→ sessionStorage stores'[object Object]', status still “Invite ready to share”.{type:"invite", invite:{capability:12345, display_name:"bob"}}
→ sessionStorage stores'12345', status still “Invite ready to share”.{type:"view", data:{not:"text"}, view_revision:"7"}→ the world view
renders'[object Object]'(and the string revision is stored).{type:"error", message:{code:42}}→ the status line shows'[object Object]'.- Control:
{type:"error", message:"world is full"}→ shown verbatim. ✔
Existing tests do not cover this: the world suites
(world-records.test.ts, world-rejoin.test.ts, world-surface.test.ts, …)
deliver only well-shaped invite/view/error frames, if any.
Why it matters
The invite capability is a credential-like value: it is persisted in
sessionStorage, rehydrated on the next load, pre-fills the capability field
the user joins with, and is what the copy button shares. A single
wrong-shape frame silently replaces a valid capability with
'[object Object]' / a coerced number and reports success — the user then
joins (or shares an invite) with a capability the server never issued, and
the failure surfaces later, elsewhere, with no trace back to the bad frame.
The view/error coercions are the same defect class at display severity:
bogus rendered state and useless error text instead of the house pattern —
validate, and rejectFrame() on a mismatch — that the snapshot/event cases
in the same switch already follow.
Related but distinct: #7908 covers the session-WS records frame in the
same receive(); #7833/#7831 cover the REST /api/world/host-view and
/api/world/invite HTTP responses in the same file (different functions and
transport — this issue is the WebSocket invite frame, not the HTTP invite
response). A fixer may reasonably handle them in one pass.
Acceptance criteria
- An
inviteframe whose effectivecapability(nestedinviteobject or top-level) is present but not a string is rejected (e.g. via the existingrejectFrame()path): nothing is written to sessionStorage or the capability field, the invite output is not shown, and “Invite ready to share” is not reported. A missing capability stays a no-op as today. - A
viewframe whosedatais present but not a string is rejected the same way and does not change the rendered view; a non-numberview_revisionis never stored as the rendered revision. - An
errorframe whosemessageis present but not a string is rejected (or falls back to the default message) — a coerced'[object Object]'is never displayed as the status or log line. - Well-formed frames behave exactly as today: valid invite capabilities are stored and reported, string view data renders, string error messages show verbatim, and the existing world suites stay green.
- New tests deliver object/numeric invite capabilities, object view
data, a stringview_revision, and an object errormessage, and pin the rejection.
Activity
developing-today commentedon Nov 9, 2026
CODE-2348
dezren39 commentedon Nov 9, 2026
🤖 Agent note · filed
new-issue-creator-code-a)invite,viewanderrorframe shapes inpkgs/id/web/src/world.tsreceive()— reject a non-string invite capability / viewdata/ errormessageinstead of persisting or rendering their coerced forms.~/git/fleet/probe-world-frames-20261108(realworld.ts, byte-identical to main @ 30bd3a1; 6/6 probe tests pass asserting the current wrong behavior; baselineworld-records.test.ts6/6 green). Related, distinct: issue 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 (session-WSrecordsframe, same switch), issues id(web/world): /api/world/host-view and /api/world/invite responses shape-trusted — a wrong-shape 200 shows raw TypeErrors, renders bogus per-character records, or persists a fake 'undefined' invite capability #7833/id(web/world): /api/world/host-view and /api/world/invite responses shape-trusted — a wrong-shape 200 shows raw TypeErrors or stores a fake 'undefined' capability #7831 (REST host-view/invite responses, different transport).dezren39 commentedon Nov 11, 2026
🤖 Agent note · parked — awaiting triage
6 remaining items
dezren39 commentedon Nov 11, 2026
agent-note:v1
state: parked
task: 14284
lane: tmp-code-v
PR #8536 opened @cf3b0466b3 (branch queue/14284-7924-world-frame-guards): invite/view/error frame guards in pkgs/id/web/src/world.ts + new pkgs/id/web/src/world-frames.test.ts.
Tests: new suite 5/5 post-fix (4/5 fail pre-fix), all 9 world suites 81/81 on laptop, tsc clean.
Parked: CI checks QUEUED on PR #8536 (fleet CI stall) and Codex review running with no findings yet. Resume: when checks complete, disposition any Codex findings, merge on green, complete task 14284 as fixed_merged.
test(id/web/world): property-based frame-shape coverage for invite/vi…
fix(id/web/world): reject wrong-shape invite/view/error frames (#7924) (
dezren39 commentedon Nov 11, 2026
agent-note:v1
state: done
task: 14284
lane: any-b
summary: PR #8536 merged (squash, merge commit 6219b31); issue #7924 auto-closed. On resume, Codex had one unresolved P1 on the original head (property-based coverage for frame-shape invariants): fixed in 70e8aaa with a fixed-seed generated-shape property test (240 frames, explicit acceptance oracle, state-preservation assertions, coverage guards for the display_name and base_view_revision branches); vitest world-frames 6 passed. Codex re-review on 70e8aaa completed with no findings.
next: none for task 14284