Does a missing COOP header disable WebAssembly shared memory in all modern browsers?
0 reputation · 13 Jul 2021, 20:17 UTC
0 reputation · 13 Jul 2021, 20:17 UTC
Goal: determine whether omitting Cross-Origin-Opener-Policy or Cross-Origin-Embedder-Policy reliably blocks WebAssembly shared memory and threads, and what failure surface appears when only one header is set.
SharedArrayBuffer and atomics are gated by browser security policy, not by the Wasm module itself. The page’s crossOriginIsolated property should be false without both headers, but Chrome, Firefox, and Safari may enforce partial configurations differently. CSP rules and sandboxed iframes can further restrict shared memory even when headers appear correct. Current stable browser versions are assumed; a side-by-side comparison with headers present and absent is the practical check.
Does Chrome treat a missing COOP header the same as a missing COEP header for Wasm thread instantiation? Which exception or rejection surface appears in Firefox and Safari when crossOriginIsolated is false? Can a page regain shared memory after adding the missing headers without reloading the origin?
34775 reputation · 13 Jul 2021, 22:26 UTC
Yes, a missing Cross-Origin-Opener-Policy (COOP) header disables WebAssembly shared memory and threads in all modern browsers. To use SharedArrayBuffer or atomics, the page must be in a "cross-origin isolated" state, which requires **both** COOP and Cross-Origin-Embedder-Policy (COEP) to be set correctly.
The security gate is not applied to the WebAssembly module itself, but to the browser's execution environment. If window.crossOriginIsolated is false, the browser will either block the creation of SharedArrayBuffer or prevent the instantiation of Wasm modules that require shared memory (threads).
When only one header is set, the browser fails to achieve isolation, and the behavior typically manifests as follows:
SharedArrayBuffer will throw a TypeError in Chrome and Firefox.crossOriginIsolated is false, a Wasm module compiled with shared memory support will usually fail to instantiate with a LinkError or TypeError because the SharedArrayBuffer constructor is not available.To enable Wasm threads and shared memory, ensure your server provides the following HTTP headers:
Cross-Origin-Opener-Policy: same-originCross-Origin-Embedder-Policy: require-corp (or credentialless-corp if handling cross-origin resources)You can verify the state by running the following in the browser console:
console.log(window.crossOriginIsolated);
A page cannot regain shared memory after adding missing headers without a full page reload. The isolation state is determined during the initial document load. If you update your headers server-side, the user must refresh the page to re-evaluate the crossOriginIsolated status.
Note: If your application runs inside a sandboxed &<iframe>, shared memory may still be blocked regardless of headers unless the iframe is specifically configured to allow it.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.