Client Wasm browser capabilities (what Apps can touch)
Research for Shell-mediated client Apps (see root CONTEXT.md).
Question: can browser WebAssembly reach network, cookies, or storage on its own, or only through JavaScript the Shell chooses to import?
Primary sources: MDN WebAssembly docs.
Executive finding
Portable browser Wasm has no ambient Web APIs. It cannot call fetch, read document.cookie, or touch localStorage / IndexedDB unless the JavaScript that instantiates the module passes those capabilities in as imports. The Shell therefore can meet the ideal: App Wasm that can do nothing outward except what the Shell bridge exposes.
Caveats are about glue and toolchains, not a hidden Wasm syscall surface.
How Wasm talks to the browser
MDN models the web platform as (1) a VM that runs JS and Wasm and (2) Web APIs (DOM, storage, etc.) (WebAssembly concepts).
Key points from that page:
- Wasm modules declare imports and exports, analogous to ES modules.
- An Instance is a module plus its runtime state and imported values.
- “Arbitrary JavaScript functions can also be synchronously called by WebAssembly code by passing in those JavaScript functions as the imports to a WebAssembly instance.”
- “By itself, WebAssembly cannot currently directly access the DOM; it can only call JavaScript… Thus, to access any Web API, WebAssembly needs to call out to JavaScript.”
- MDN notes future plans to allow Wasm to call Web APIs directly — treat as a watch item for the security story, not today’s default.
Loading APIs (WebAssembly.instantiate / instantiateStreaming) take an importObject; missing required imports fail instantiation (Using the JavaScript API; instantiateStreaming).
Implications for personal-cloud
| Capability | Ambient to App Wasm? | How an App would get it |
|---|---|---|
HTTP fetch / XHR |
No | Only if Shell imports a function that calls fetch |
| Cookies (read) | No | Only if Shell imports cookie access; HttpOnly cookies are never JS-readable anyway |
| Cookies (send on request) | N/A inside Wasm | Only if some imported function performs a credentialed request |
localStorage / IndexedDB |
No | Only if Shell imports storage helpers |
| DOM | No (today) | Only via Shell-mediated UI bridge (already locked: Shell owns DOM) |
| Timers / Worker APIs | No | Only if Shell runs Wasm inside a worker and imports those APIs |
Durable Shell session (cookies or equivalent) can live in the normal browser session for the Shell origin. App Wasm never sees it if the Shell does not import cookie/storage accessors and does not import a raw fetch that attaches credentials. Long-lived login for “new tab” is a Shell concern; Apps get results through the bridge, not the session secret.
Failure modes (still real)
- Hostile or sloppy glue — If the Shell (or an App-shipped JS loader) imports full
fetch+ credentialed requests, Wasm is as powerful as that glue. Spec must: Host/Shell owns instantiation; App packages must not supply main-thread JS loaders (already locked). - Emscripten-style POSIX shims — Toolchains often generate JS glue that implements libc networking in terms of Web APIs (MDN concepts — Emscripten). Shipping that glue as “the App” would reintroduce ambient network. Mitigation: instantiate with a Host-defined WIT/bridge import set only; reject or strip App-provided ambient shims.
- Same-origin workers with ambient
fetch— A worker is still JS. If Shell starts a worker whose script canfetchwith cookies, that is not “Wasm escaping”; it is glue misdesign. Same bar: worker script is Shell-owned; only bridge imports are exposed to the Wasm instance inside. - Future direct Web API access from Wasm — Revisit import-only assumption if browsers ship that (MDN concepts).
Lesson for auth grilling
You do not need a dual-token HTML+client scheme to stop Apps from “using the session cookie.” If App Wasm has no network import and no storage/cookie import, it cannot exfiltrate or replay the Shell session. The Shell JS holds the session and performs Host calls on the App’s behalf, asserting install id server-side.
Cross-App isolation then reduces to: per-install bridge handles, Host-enforced Grants, and Host-mediated storage keyed by install id — not browser origin tricks on a single hostname.