Skip to content

fix(security): 2 improvements across 2 files#8565

Open
tomaioo wants to merge 2 commits into
breadboard-ai:mainfrom
tomaioo:fix/security/unsafe-vm-code-execution-without-sandbox
Open

fix(security): 2 improvements across 2 files#8565
tomaioo wants to merge 2 commits into
breadboard-ai:mainfrom
tomaioo:fix/security/unsafe-vm-code-execution-without-sandbox

Conversation

@tomaioo
Copy link
Copy Markdown

@tomaioo tomaioo commented May 23, 2026

Summary

fix(security): 2 improvements across 2 files

Problem

Severity: High | File: experiments/logic/src/run-in-vm.ts:L12

The prepareToRunInVM function in run-in-vm.ts uses Node.js vm module's createContext with an empty object and SourceTextModule to execute dynamically generated code. While it blocks dynamic imports via the linker, the context is not fully sandboxed - the code can still access the global object and potentially escape the VM context. This is used to execute AI-generated code in run-test.ts which compounds the risk since the code origin is untrusted (AI-generated).

Solution

Consider using a proper sandbox like vm2 (with caveats) or better yet, isolate the execution in a separate process with restricted permissions. At minimum, freeze the context prototype chain and explicitly deny access to require, process, and other dangerous globals. Consider using isolated-vm package for proper V8 isolates.

Changes

  • experiments/logic/src/run-in-vm.ts (modified)
  • experiments/logic/src/file-ops.ts (modified)

tomaioo added 2 commits May 23, 2026 11:36
- Security: Unsafe VM Code Execution Without Sandboxing
- Security: Path Traversal in File Operations

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
- Security: Unsafe VM Code Execution Without Sandboxing
- Security: Path Traversal in File Operations

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 23, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

1 participant