openinterpreter icon indicating copy to clipboard operation
openinterpreter copied to clipboard

Implement Sandbox

Open SuperPat45 opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe.

Generated code can access to all files of the system which is a huge security concern in server environment.

Describe the solution you'd like

I would like to have an option "doker image name for sandbox" in open interpreter which automatically start the mentioned docker image and execute the generated code inside the closed docker environment.

Describe alternatives you've considered

No response

Additional context

No response

SuperPat45 avatar Nov 21 '24 17:11 SuperPat45

+1 on the need for sandboxing. Docker is one option but adds ~200ms startup overhead per code execution and requires a daemon.

A lighter-weight alternative: sandlock, which uses Landlock, seccomp-bpf, and user namespaces to sandbox processes at the kernel level on Linux.

For Open Interpreter's execution model, sandlock could wrap both the subprocess.Popen calls (shell/JS/Ruby) and the Jupyter kernel process:

Protection How
Filesystem Landlock path whitelisting: LLM-generated code can only read/write allowed directories
Network Domain + port allowlisting: prevent data exfiltration to arbitrary hosts
Syscalls seccomp-bpf filtering: block dangerous syscalls (ptrace, mount, unshare, etc.)
Resources Memory, process count, CPU, open file limits

Key advantages over Docker for this use case:

  • ~20ms startup vs ~200ms (matters when executing code blocks frequently)
  • No root, no daemon. Just pip install sandlock
  • Per-execution policy. Each code block gets its own sandbox with configurable restrictions
  • Works alongside the existing Jupyter kernel. The kernel process itself runs inside the sandbox

Example of what integration could look like:

from sandlock import Sandbox

sandbox = Sandbox(
    fs_read=["/usr/lib", "/usr/local/lib", project_dir],
    fs_write=[project_dir],
    net_allow=["api.openai.com:443"],
    max_memory_mb=512,
)

# Wrap existing subprocess.Popen
sandbox.run(["bash", "-c", llm_generated_code])

This would address the "huge security concern in server environment" mentioned in the original issue without requiring users to set up Docker.

Disclosure: I'm the author of sandlock.

congwang-mk avatar Mar 27 '26 22:03 congwang-mk

Thank you for reporting this and for helping build the classic Python version of Open Interpreter. This issue concerns the earlier Python/LiteLLM/Jupyter product; this repository now tracks the Rust Open Interpreter built on Codex. We are closing the legacy report here so current product tracking starts clean. If you still want to pursue it, the community-maintained classic fork is https://github.com/endolith/open-interpreter. If the same problem affects the current Interpreter release, please open a new issue with the current template and include the version, provider, model, wire API, harness, platform, and reproduction.

interpreterwork avatar Jul 28 '26 04:07 interpreterwork