Add comprehensive research on Node.js sandboxing capabilities#100
Merged
Add comprehensive research on Node.js sandboxing capabilities#100
Conversation
…, vm2, quickjs-emscripten, ShadowRealm, Deno Workers https://claude.ai/code/session_019VCn2aGgVfuSqP4qK2G4Lf
Covers Worker constructor options, resourceLimits, Permission Model (now stable in v22), vm module limitations, and third-party packages (isolated-vm, quickjs-emscripten). Includes verified code examples demonstrating defense-in-depth sandboxing with Worker + Permission Model + vm module. https://claude.ai/code/session_019VCn2aGgVfuSqP4qK2G4Lf
Investigated filesystem, network, memory, and CPU isolation options for running untrusted JavaScript via worker_threads on Node.js 22. Key findings: - resourceLimits does NOT enforce memory limits (workers exceed by 10-20x) - Permission Model (--experimental-permission) works via worker execArgv - vm module is NOT a security boundary (trivially escapable) - isolated-vm provides hard memory limits, CPU timeout, and true isolation - Permission Model blocks native addons by default (needs --allow-addons) - Defense in depth: permission model catches vm sandbox escapes Recommended: Worker + isolated-vm, with Permission Model as optional layer. https://claude.ai/code/session_019VCn2aGgVfuSqP4qK2G4Lf
Owner
Author
|
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.
Summary
This PR adds extensive research documentation and working examples for sandboxing untrusted JavaScript code using Node.js v22 built-in modules and third-party packages. The research covers worker_threads, the Permission Model, vm module, and npm packages like isolated-vm.
Key Changes
Documentation
Working Examples
--experimental-permissionviaexecArgvsuccessfully blocks filesystem writes and child process spawningNotable Implementation Details
--max-old-space-sizecannot be passed via execArgv--allow-addonspermission flagAll examples are tested and functional on Node.js v22.22.0.
https://claude.ai/code/session_019VCn2aGgVfuSqP4qK2G4Lf