feat: add sandlock as lightweight OS-level sandboxing backend for CodeInterpreterTool#5151
Open
devin-ai-integration[bot] wants to merge 7 commits intomainfrom
Open
feat: add sandlock as lightweight OS-level sandboxing backend for CodeInterpreterTool#5151devin-ai-integration[bot] wants to merge 7 commits intomainfrom
devin-ai-integration[bot] wants to merge 7 commits intomainfrom
Conversation
…e execution Addresses #5150 - adds sandlock (Landlock + seccomp-bpf) as a new execution backend for CodeInterpreterTool, providing kernel-level process isolation without requiring Docker. Changes: - Add 'execution_backend' parameter to CodeInterpreterTool with options: 'auto' (default), 'docker', 'sandlock', 'unsafe' - Add sandbox configuration options: sandbox_fs_read, sandbox_fs_write, sandbox_max_memory_mb, sandbox_max_processes, sandbox_timeout - Add run_code_in_sandlock() method using sandlock's Sandbox/Policy API - Add _check_sandlock_available() to verify Linux + sandlock installation - Add _build_sandlock_policy() to construct sandlock Policy from config - Update run_code_safety() to fall back to sandlock when Docker unavailable - Update error messages to mention sandlock as an alternative - Add 'sandlock' optional dependency in pyproject.toml - Add 18 new tests covering all sandlock integration paths Co-Authored-By: João <joao@crewai.com>
Contributor
Author
|
Prompt hidden (unlisted session) |
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: João <joao@crewai.com>
…mports Co-Authored-By: João <joao@crewai.com>
… ignores Co-Authored-By: João <joao@crewai.com>
…r pattern) Co-Authored-By: João <joao@crewai.com>
…y cached by mypy) Co-Authored-By: João <joao@crewai.com>
Member
|
How will this affect Windows-based deployments? |
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
Implements #5150 — adds sandlock as a new lightweight execution backend for
CodeInterpreterTool. Sandlock uses Linux kernel features (Landlock + seccomp-bpf) to provide process-level isolation without requiring Docker.Key changes:
execution_backendparameter onCodeInterpreterTool:"auto"(default),"docker","sandlock","unsafe"sandbox_fs_read,sandbox_fs_write,sandbox_max_memory_mb,sandbox_max_processes,sandbox_timeoutrun_code_in_sandlock()method with library installation, policy building, and error handlingsandlock>=0.2.0added as an optional dependency group inpyproject.tomlReview & Testing Checklist for Human
SandboxandPolicy— the real sandlock API (Sandbox(policy).run(cmd, timeout=...)returning an object with.stdout,.stderr,.returncode) has not been integration-tested. Thehasattr()guards on lines 530-532 suggest uncertainty about the return type. Confirm the actualsandlock>=0.2.0package exposes this interface.run_code_in_sandlockinstalls pip packages on the host filesystem (viasubprocess.run) before entering the sandbox. Compare with Docker backend which installs inside the container. Untrusted library names get passed topip install --target._build_sandlock_policyfilesystem permissions. The policy adds allsys.pathentries as readable paths and usesexec(open('{code_file}').read())for execution. Verify this doesn't expose more of the host filesystem than intended.sandlockpackage maturity/trust. sandlock v0.2.0 is a relatively new/small package. Evaluate whether it meets the bar for a crewAI dependency (even as optional).CodeInterpreterTool(execution_backend="sandlock")with real code, and verify isolation (e.g., confirm filesystem writes outside allowed paths are blocked, memory limits enforced).Notes
test_docker_unavailable_raises_errorwas renamed totest_docker_and_sandlock_unavailable_raises_errorand its assertions updated to reflect the new fallback chain.sandlockis Linux-only (requires kernel 5.13+). The implementation gracefully rejects non-Linux platforms with a helpful error message.unsafe_mode=Trueflag continues to work as before for backward compatibility.Updates since last revision
Policyimport uses# type: ignore[import-untyped](matching the existingdockerimport pattern), and theSandboximport needs no annotation since mypy caches the module after the first import.Link to Devin session: https://app.devin.ai/sessions/cd127bbc88684d649b90b1272c9a520b