Skip to content

fix(v8): close the asm.js bypass of WebAssembly restrictions - #96

Closed
theduke wants to merge 1 commit into
split/napi-03-guest-accountingfrom
split/napi-04-asmjs
Closed

theduke wants to merge 1 commit into
split/napi-03-guest-accountingfrom
split/napi-04-asmjs

Conversation

@theduke

@theduke theduke commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Removing the WebAssembly global and refusing WebAssembly code generation did not cover V8's asm.js validator. A use asm script could enter V8's translated-Wasm compiler and allocate code outside the guest allocator and embedder policy.

Add --no-validate-asm to the provider's default flags. asm.js executes as ordinary JavaScript through the normal JS compilation tiers. This closes the bypass without adding an API or enabling WebAssembly.

Older Emscripten asm.js bundles may lose numeric-workload performance; their JavaScript results remain unchanged. The regression inspects the running caller frame to distinguish ordinary JavaScript from translated Wasm.

Stack and provenance

#93 → #94 → #95 → #96 → #97 → #98 → #99 → #100 → #101

Part 4 of the audited split of #84, reconstructed on current main eac0a13fa65a4d6103864d875ed76ab7efb1816e. Review against split/napi-03-guest-accounting; predecessor branches are required. Original PR #84 remains unchanged. The stack preserves newer main host-JS behavior and deliberately excludes the unused frozen 0.0.1 ABI adapter.

Validation

v8_host_control::asm_js_runs_as_plain_javascript and default V8 flag assertions.

The integrated standalone host-control run completed 20 of 21 cases successfully, including the unchanged asm.js probe. The sole failure was finite-budget shared-message detachment on the older public SDK; the same message case passed on the intended Edge SDK. Final branch CI remains pending. No further local tests were run after the user requested they stop.

Latest-main rebase

Rebased the dependency stack onto eac0a13fa65a4d6103864d875ed76ab7efb1816e after main merged PR #92. This preserves unsigned guest IDs, pointers and lengths, bounded result/argv writes, host-JS buffer failure cleanup and the high-pointer/high-ID regressions. Conflicts received independent native and host-JS source review. All historical local results above predate this rebase; no local tests or builds were run for it, as requested. Updated-head validation belongs to CI and may be pending. This PR keeps its prerequisite branch as its base to preserve the focused diff.

@theduke
theduke force-pushed the split/napi-04-asmjs branch from a16ae5d to e77702f Compare October 22, 2026 08:20
@theduke
theduke added this pull request to stack #102 October 22, 2026 08:24
@theduke
theduke marked this pull request as ready for review October 22, 2026 08:26

@syrusakbary syrusakbary left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address feedback

"--js-explicit-resource-management "
"--js-float16array";
"--js-float16array "
"--no-validate-asm";

@syrusakbary syrusakbary Oct 22, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would prevent to use optimized Wasm when needed for asm.js.

What we need to --no-validate-asm if and only if wasm is not supported. If Wasm is supported, then we shouldn't add this flag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants