Skip to content

id(web/world): upload/compile socket error, module_installed and compiled fields shape-trusted — non-string message/module_hash/diagnostics render coerced and a bogus installed frame still clears the admin token #7928

Closed

Description

@dezren39

id(web/world): upload/compile socket error, module_installed and compiled fields shape-trusted — non-string message/module_hash/diagnostics render coerced ('[object Object]', 'a,b') and a bogus installed frame still clears the admin token

Summary

The two admin WebSocket handlers in pkgs/id/web/src/world.ts — the wasm module-upload socket and the Roc-compile socket — validate the frame envelope and chunk_bytes, but trust the fields of the error, module_installed and compiled frames. A wrong-shape frame from the host (deploy skew, a buggy/future server, a middlebox) is not rejected: its non-string message, module_hash and diagnostics are rendered as their coerced string form, and a module_installed/compiled frame with a bogus hash still reports success in green and clears the admin token input.

Evidence (verified this run, laptop @ origin/main 0f9e471; world.ts byte-identical to the probe copy)

pkgs/id/web/src/world.ts:

  • Upload socket handler (:617-675): after isRecord + string-type check, const frame = parsed as WorldFrame; (:631). error case (:632-635): setStatus(frame.message ?? "Module install failed", "error") — message unchecked. module_installed case (:668-673): setStatus(`World program installed: ${frame.module_hash ?? "ok"}`, "good"), log line with the same value, and admin.value = "" — module_hash unchecked, success side effects unconditional.
  • Compile socket handler (:750-776): same cast (:764). error case (:765-768): status + log from unchecked frame.message. compiled case (:769-775): status + log from unchecked frame.module_hash, and if (frame.diagnostics) appendLine(log, frame.diagnostics) — diagnostics unchecked; success also clears admin.value.
  • Sibling in the same handlers is validated: upload_ready's chunk_bytes must be an integer in 1..6144 (:639-651) or the socket closes with an invalid-size status. The session socket's receive() likewise validates snapshot/event fields (isWorldSnapshot/isWorldEvent) and rejects bad frames via rejectFrame().
  • Declared contract (world.ts :39-44): chunk_bytes?: number; module_hash?: string; diagnostics?: string; message?: string — all string fields, none enforced in these two handlers.

Reproduction (probe on the laptop, ~/git/fleet/probe-world-upload-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 baseline world-records.test.ts is 6/6 green):

  • Control: install {type:"error", message:"bad module"} → status bad module. ✔
  • Install {type:"error", message:{forged:true}} → status [object Object].
  • Install {type:"module_installed", module_hash:{forged:true}} → status World program installed: [object Object], log program installed [object Object], admin token cleared.
  • Install {type:"module_installed", module_hash:12345} → status World program installed: 12345.
  • Compile {type:"error", message:["a","b"]} → status a,b, log compile error: a,b.
  • Compile {type:"compiled", module_hash:{forged:true}, diagnostics:{diag:1}} → status Roc program installed: [object Object], diagnostics appended to the log as [object Object].

Dedup / scope boundaries

Why it matters

These are the admin paths that install a world program. A host that answers with a wrong-shape success frame makes the page claim a program was installed under a hash that is literally [object Object] (or 12345), clears the admin token as if the install completed, and logs the same fiction — the operator has no signal anything went wrong, and the real error text (when the frame is an error) is replaced by coerced garbage instead of the host's message or a clean invalid-response status. The handlers already have the invalid-response path ("Host returned an invalid upload/compile response" + close); the field checks belong on the same path.

Acceptance criteria

  • In both handlers, an error frame whose message is present and not a string, a module_installed/compiled frame whose module_hash is present and not a string, and a compiled frame whose diagnostics is present and not a string take the existing invalid-response path (invalid upload/compile response status, socket closed) — no coerced rendering, no success status, and the admin token is NOT cleared.
  • Well-formed frames behave exactly as today: string message renders as the error status, string module_hash renders in the success status/log and clears the admin token, string diagnostics is appended to the log.
  • Web tests cover the malformed field cases for both sockets (object/array message, object/numeric module_hash, object diagnostics) plus the well-formed controls; the existing world web suites still pass.

Activity

  1. developing-today commented on Nov 9, 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/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    effort/xsTrivial: expected under 30 minutes of work
    on Nov 9, 2026
  3. dezren39 commented on Nov 9, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-b)
    • Session / ID: cron job new-issue-creator-code-b, run 2026-11-08 20:20 CST
    • Found via: filed this run
    • Task: Validate the fields of the upload/compile socket error, module_installed and compiled frames in pkgs/id/web/src/world.ts (message/module_hash/diagnostics must be strings when present) via the existing invalid-response path, so a bogus success frame no longer reports a coerced hash or clears the admin token
    • Expectation: effort/xs — done when malformed field frames take the invalid-response path in both handlers, well-formed frames behave as today, and web tests cover both sockets
    • Links: evidence read on laptop at origin/main 0f9e471 (world.ts:617-675 upload handler, :750-776 compile handler, chunk_bytes sibling validation :639-651); probe ~/git/fleet/probe-world-upload-20261108 (real world.ts byte-identical, 6/6 probe, baseline world-records 6/6); body file creator-b-2026-11-08-2020/issue-body.md in the goal hidden_files
  4. dezren39 commented on Nov 10, 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
    on Nov 10, 2026
  6. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · Triage (inline, §1c)

    • Agent: repo-worker-code (lane code-d, queue task 14291)
    • Labels: already correct — task/small-fix, priority/normal, effort/xs, kind/bug, app/id. No design fork (message labels + identity say how to fix it); proceeding to implementation on this claim.
    • Bug, verified on current main: the upload handler (world.ts :631) and compile handler (:764) check isRecord + string type and validate upload_ready chunk_bytes, then cast to WorldFrame and use message / module_hash / diagnostics unchecked — an object message renders [object Object], an array message a,b, an object/numeric module_hash renders as a bogus success hash, and a bogus module_installed/compiled frame still clears the admin token.
    • Fix: present-but-non-string message/module_hash/diagnostics in either handler takes that handler's existing invalid-response path (invalid status + socket close, no success side effects); well-formed frames unchanged; behavioral tests in the world-records harness pattern cover both sockets.
  7. 10 remaining items

  8. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    Agent note — task 14291 picked up (lane any-a): resuming PR #8511 to merge

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

    @dezren39
    MemberAuthor

    Agent note — task 14291 done (lane any-a): PR #8511 merged

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/xsTrivial: expected under 30 minutes 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