Repository navigation
Description
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-typecheck,const frame = parsed as WorldFrame;(:631).errorcase (:632-635):setStatus(frame.message ?? "Module install failed", "error")—messageunchecked.module_installedcase (:668-673):setStatus(`World program installed: ${frame.module_hash ?? "ok"}`, "good"), log line with the same value, andadmin.value = ""—module_hashunchecked, success side effects unconditional. - Compile socket handler (:750-776): same cast (:764).
errorcase (:765-768): status + log from uncheckedframe.message.compiledcase (:769-775): status + log from uncheckedframe.module_hash, andif (frame.diagnostics) appendLine(log, frame.diagnostics)—diagnosticsunchecked; success also clearsadmin.value. - Sibling in the same handlers is validated:
upload_ready'schunk_bytesmust be an integer in 1..6144 (:639-651) or the socket closes with an invalid-size status. The session socket'sreceive()likewise validates snapshot/event fields (isWorldSnapshot/isWorldEvent) and rejects bad frames viarejectFrame(). - 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"}→ statusbad module. ✔ - Install
{type:"error", message:{forged:true}}→ status[object Object]. - Install
{type:"module_installed", module_hash:{forged:true}}→ statusWorld program installed: [object Object], logprogram installed [object Object], admin token cleared. - Install
{type:"module_installed", module_hash:12345}→ statusWorld program installed: 12345. - Compile
{type:"error", message:["a","b"]}→ statusa,b, logcompile error: a,b. - Compile
{type:"compiled", module_hash:{forged:true}, diagnostics:{diag:1}}→ statusRoc program installed: [object Object], diagnostics appended to the log as[object Object].
Dedup / scope boundaries
- id(web/world): upload and compile socket handlers cast JSON.parse straight to WorldFrame — non-object frames crash or hang the flow, non-integer chunk_bytes corrupts the chunk stream #5034 (closed) covered these same handlers at the frame level (non-object frames, non-integer
chunk_bytes) — both fixed, and the chunk validation is the sibling pattern above. It did not cover the per-field types oferror/module_installed/compiled. - 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 (open) covers the session socket's
receive()fields (invite/view/error). These upload/compile sockets are separate handlers with separate sockets; 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's fix does not touch them. - id(world_net): compile() silently defaults a malformed 'compiled' reply — missing/mistyped module_hash, sequence and diagnostics all read as Ok(("", 0, "")) #6620 (closed) was the Rust
world_netclient'scompiledreply — a different consumer in a different language.
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
errorframe whosemessageis present and not a string, amodule_installed/compiledframe whosemodule_hashis present and not a string, and acompiledframe whosediagnosticsis 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
messagerenders as the error status, stringmodule_hashrenders in the success status/log and clears the admin token, stringdiagnosticsis appended to the log. - Web tests cover the malformed field cases for both sockets (object/array
message, object/numericmodule_hash, objectdiagnostics) plus the well-formed controls; the existing world web suites still pass.
Activity
developing-today commentedon Nov 9, 2026
CODE-2350
dezren39 commentedon Nov 9, 2026
🤖 Agent note · filed
error,module_installedandcompiledframes 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 tokendezren39 commentedon Nov 10, 2026
🤖 Agent note · parked (awaiting triage)
dezren39 commentedon Nov 11, 2026
🤖 Agent note · Triage (inline, §1c)
:631) and compile handler (:764) checkisRecord+ stringtypeand validateupload_readychunk_bytes, then cast to WorldFrame and usemessage/module_hash/diagnosticsunchecked — an object message renders[object Object], an array messagea,b, an object/numeric module_hash renders as a bogus success hash, and a bogus module_installed/compiled frame still clears the admin token.10 remaining items
dezren39 commentedon Nov 11, 2026
Agent note — task 14291 picked up (lane any-a): resuming PR #8511 to merge
directqueue/14291-7928-world-frame-fields; issue 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 is OPEN with no hard-stop labels and nostatus/needs-triage(triage labels already present: task/small-fix, priority/normal, effort/xs, kind/bug). Prior checkpoint: vitest 15/15, tsc clean at the PR head.Merge pull request #8511 from developing-today/queue/14291-7928-world…
dezren39 commentedon Nov 11, 2026
Agent note — task 14291 done (lane any-a): PR #8511 merged
pkgs/id/web/src/world.tsnow route present-but-non-stringmessage/module_hash/diagnosticsfields to the handler's invalid-response path: no coerced rendering ("[object Object]", "a,b"), and a bogusmodule_installed/compiledframe no longer clears the admin token. Well-formed frames behave exactly as before.src/world-upload-compile.test.ts9/9 passed andtsc --noEmitclean on the laptop at the PR head (5e9a25e); no Codex review comments exist on the PR; PR checks showed no failures (most CANCELLED, snapshot-determinism SUCCESS, 2 still QUEUED at merge — merge made under standing authority on the local evidence).