Skip to content

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

Closed

Description

@dezren39

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.records is consumed by Object.entries(result.records) (:444) and result.records_sequence is 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, and result.capability goes straight to showCapability (:181-185), which assigns it to the capability input and persists it via sessionStorage.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" persisted
  • null: status shows the raw TypeError null 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 TypeError null is not an object (evaluating 'result.records_sequence')
  • {}, {records: null, …}, []: status shows the raw TypeError Object.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) — showCapability is never called, nothing is written to sessionStorage, and no success status is shown. display_name falls back gracefully when absent/wrong-typed.
  • The host-view response is validated per page before any state is touched: body must be an object, records must be a plain object, records_sequence a finite number, next_after a string or null, and snapshot (when present) must satisfy the existing isWorldSnapshot guard — 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

  1. developing-today commented on Nov 8, 2026

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

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  4. added
    work/assignedQueue worker lifecycle state
    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
  5. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    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.

  6. 8 remaining items

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

    @dezren39
    MemberAuthor

    🤖 Agent note · fixed and merged — PR #8532 (task 14008, lane code-a)

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/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted testswork/assignedQueue worker lifecycle state

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions