Skip to content

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

Closed

Description

@dezren39

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 contract invite?: { capability?: string; … },
    data?: string, view_revision?: number, message?: string (~lines 24–44).
  • Sibling cases validate before use: snapshot is checked with
    isWorldSnapshot, event with isWorldEvent, and the records case 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 to rejectFrame(). The upload
    socket in the same file validates chunk_bytes (integer, 1..6144) before use.
  • The invite case (~lines 297–305) has no equivalent guard:
    const invite = frame.invite ?? frame; if (invite.capability) { showCapability(invite.capability); … }
    — any truthy value is passed to showCapability (~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 view case (~lines 237–266): the surface path is guarded by
    renderWorldSurface, and the patch path 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 object data renders as '[object Object]', and a
    non-number view_revision is stored verbatim as the rendered revision,
    after which patch base-revision comparisons can never match it.
  • The error case (~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 stores cap-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 invite frame whose effective capability (nested invite object or top-level) is present but not a string is rejected (e.g. via the existing rejectFrame() 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 view frame whose data is present but not a string is rejected the same way and does not change the rendered view; a non-number view_revision is never stored as the rendered revision.
  • An error frame whose message is 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 string view_revision, and an object error message, and pin the rejection.

Activity

  1. developing-today commented on Nov 9, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 9, 2026
  3. dezren39 commented on Nov 9, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  4. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked — awaiting triage

  5. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 11, 2026
  6. 6 remaining items

  7. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    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.

  8. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 11, 2026
  9. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    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

  10. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions