feat: configurable JS runtime platform (CreateVmConfig.jsRuntime)#78
Merged
Conversation
|
🚅 Environment secure-exec-pr-78 in rivet-frontend has no services deployed. |
Add a jsRuntime config to choose which JavaScript host environment guest code sees, modeled on esbuild's platform: - platform: node | browser | neutral | bare - moduleResolution: node | relative | none (independent axis) - allowedBuiltins: tri-state Option (node platform only) Non-node platforms are produced by subtractively scrubbing baked globals in the per-execution runtime shim (the V8 snapshot is shared, so tiering can't live in setupGlobals). Builtin denial is enforced at the bridge's rejectRestrictedBuiltinRequest sink via a one-shot init fn (no reachable __agentOs* global); moduleResolution is gated at the Rust resolver. browser narrows crypto to WebCrypto and keeps npm/ESM->CJS interop working. Removes the legacy configure_vm.allowed_node_builtins field end-to-end (BARE schema + generated wire types + ~40 call sites). Adds docs page (features/runtime-platform) + spec. vm-config validation + an execution-level pentest suite prove the surface is actually disabled (process/Buffer/require/ node:* unreachable, identity channels scrubbed, imports denied per mode). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
NathanFlurry
force-pushed
the
feat/js-runtime-platform
branch
from
June 19, 2026 07:42
3d60364 to
58f62ba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
CreateVmConfig.jsRuntimeso callers can choose which JavaScript host environment guest code sees — modeled on esbuild'splatform. Omitting it is byte-for-byte today's behavior (full Node.js emulation).platform:node|browser|neutral|bare(esbuild's three + a sanctioned language-only tier)moduleResolution:node|relative|none(independent axis)allowedBuiltins: tri-stateOption— omitted = engine default,[]= deny all,[..]= exactly those (node platform only)process/Buffer/require…)node:*builtinsfetch/URL/WebCrypto…)console/timers)How
prepend_v8_runtime_shim) — not by gating the config-blindsetupGlobals().rejectRestrictedBuiltinRequestsink (the chokepoint forimport/import()/require), via a one-shot__agentOsInitJsRuntimeinit fn that stores the allow-list in a bridge closure and is deleted by the shim — no reachable__agentOs*global remains.moduleResolutionis gated at the Rust resolver (MODULE_NOT_FOUNDfor denied bare/relative); builtin denial surfaces uniformly asERR_ACCESS_DENIED.browsernarrowscryptoto WebCrypto (norandomBytes) and keeps npm/ESM→CJS interop working (module machinery_requireFrom/_moduleModuleis governed bymoduleResolution, not stripped by platform)._processConfig,__agentOsProcessConfigEnv) are scrubbed for non-node platforms.configure_vm.allowed_node_builtinsfield end-to-end (BARE schema → generated wire types → ~40 call sites).Docs & spec
website/src/content/docs/docs/features/runtime-platform.mdx) with the full matrix + examples.specs/js-runtime-platform.md(peer-reviewed; the wiring reflects the corrected mechanism).baredocumented as the one sanctioned extension.Testing
vm-config: 41 unit tests (validation, tri-state, everyplatform × moduleResolutionround-trip).crates/execution/tests/javascript_v8.rs, injavascript_v8_suite) proving the surface is actually disabled: underbare,process/Buffer/require/node:*/timers/console/identity channels are unreachable (incl. via theFunctionconstructor) while language + WebAssembly remain;browserexposes web globals, deniesnode:fswithERR_ACCESS_DENIED, loads a CJS npm package, and keepsfetchcallable;moduleResolution: none/relativedeny imports as specified; nodeallowedBuiltins:["path"]permitspath, deniesfs.check-types, full sidecar lib+tests build, andpnpm --dir website buildall green.