Repository navigation
Description
Problem
id(web/world): the world page shape-trusts both of its HTTP responses — a wrong-shape 200 from /api/world/host-view or /api/world/invite surfaces raw engine TypeErrors, renders bogus records, or persists a fake invite capability while reporting success.
pkgs/id/web/src/world.ts (origin/main 8728f5c, md5 2c4c46aab13c1bf9be119c0c6f373a5b):
:433— host view:const result = (await response.json()) as { snapshot?; view?; surface?; records_sequence; records; next_after }is a bare cast.result.recordsis consumed byObject.entries(result.records)(:444) andresult.records_sequenceis read at :441 with no validation. The same file's WebSocket path validates every frame (isWorldSnapshot/isWorldEvent, :156-175) — the HTTP path validates nothing.:566— invite:const result = (await response.json()) as { capability: string; display_name: string }is a bare cast, andresult.capabilitygoes straight toshowCapability(:181-185), which assigns it to the capability input and persists it viasessionStorage.setItem(storageKey, value).
Evidence (verified this run, laptop, git-archive snapshot of origin/main 8728f5c)
Probe ~/git/fleet/probe-world-shape/probe.ts (bun, minimal DOM stub, stub fetch, the real world.ts imported from the snapshot; the page's real click handlers driven end to end):
Invite (POST /api/world/invite):
- control
{capability: "cap-abc-123", display_name: "guest"}: OK — capability + sessionStorage =cap-abc-123, status "Invite created…" {}: fake success — status "Invite created. Copy it or join this browser.", capability input ="undefined", sessionStorage persists the string"undefined"(so the bogus capability survives reload and a later Join sends it as the token)"abc": same fake success,"undefined"persistednull: status shows the raw TypeErrornull is not an object (evaluating 'result.capability'){capability: 123}: status success, capability/sessionStorage ="123"(non-string silently coerced)
Host view (GET /api/world/host-view):
- control (valid snapshot/view/records page): OK — status "Read-only host view", records rendered
null: status shows the raw TypeErrornull is not an object (evaluating 'result.records_sequence'){},{records: null, …},[]: status shows the raw TypeErrorObject.entries requires that input parameter not be null or undefined{records: "abc", records_sequence: 1, next_after: null}: silently renders bogus records — records view shows{"0": "a", "1": "b", "2": "c"}(per-character entries of the string) with the "Read-only host view" success status
Why it matters
The invite path is the worst case: a malformed 200 (deploy skew, an error envelope returned with 200, a future server field change) tells the host an invite was created and stores the literal string undefined as the guest capability in sessionStorage — the host shares/joins with a credential that was never minted, and the poisoned value persists across reloads. The host view is the admin's read-only window into a world; rendering per-character garbage records as a successful read, or raw engine errors instead of the designed "Host view unavailable" message, breaks the fail-closed discipline the same file already applies to its WebSocket frames and that the sibling pages adopted in #7811/#7812/#7823.
Acceptance criteria
- The invite response is validated at the fetch boundary: a non-object body, or a missing/non-string/empty
capability, fails through the existing error path ("Invite failed" vocabulary) —showCapabilityis never called, nothing is written to sessionStorage, and no success status is shown.display_namefalls back gracefully when absent/wrong-typed. - The host-view response is validated per page before any state is touched: body must be an object,
recordsmust be a plain object,records_sequencea finite number,next_aftera string or null, andsnapshot(when present) must satisfy the existingisWorldSnapshotguard — a malformed page shows "Host view unavailable" (or the existing designed error vocabulary), never a raw TypeError, and never renders partial/bogus records. - Regression tests cover the malformed cases above for both endpoints (null, {}, array, string body, wrong-typed
capability/records) plus the well-formed controls. - pkgs/id web suite + typecheck green.
Related: #7811 / #7812 / #7823 (same shape-trust class in sibling id web pages; #7823 fixed by PR #7827 with a parseUploadResponse boundary validator — the same pattern applies here). The WebSocket frame paths in this file are already guarded and are out of scope.
Activity
developing-today commentedon Nov 8, 2026
CODE-2330
dezren39 commentedon Nov 8, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 11, 2026
Picked up task 14008 and checked the issue: it remains open and needs dedicated triage. Parked the fix for 30 minutes pending that triage; no implementation started.
8 remaining items
Merge pull request #8532 from developing-today/queue/14008-7833-world…
dezren39 commentedon Nov 11, 2026
🤖 Agent note · fixed and merged — PR #8532 (task 14008, lane code-a)