|
|
5 månader sedan | |
|---|---|---|
| .. | ||
| asserts | 5 månader sedan | |
| executor_manager | 5 månader sedan | |
| sandbox_base_image | 5 månader sedan | |
| scripts | 5 månader sedan | |
| tests | 5 månader sedan | |
| Makefile | 5 månader sedan | |
| README.md | 5 månader sedan | |
| docker-compose.yml | 5 månader sedan | |
| pyproject.toml | 5 månader sedan | |
| uv.lock | 5 månader sedan | |
A secure, pluggable code execution backend for RAGFlow and beyond.
code component.seccomp settings as needed.Makefile.
24.0.0v2.26.1 like RAGFlowWe use isolated base images for secure containerized execution:
# Build base images manually
docker build -t sandbox-base-python:latest ./sandbox_base_image/python
docker build -t sandbox-base-nodejs:latest ./sandbox_base_image/nodejs
# OR use Makefile
make build
Then, build the executor manager image:
docker build -t sandbox-executor-manager:latest ./executor_manager
Configure your .env in docker/.env:
Add the following line to /etc/hosts as recommended:
127.0.0.1 sandbox-executor-manager
cp .env.example .env
docker compose -f docker-compose.yml up
source .venv/bin/activate
export PYTHONPATH=$(pwd)
uv pip install -r executor_manager/requirements.txt
uv run tests/sandbox_security_tests_full.py
make # setup + build + launch + test
docker logs -f sandbox-executor-manager # Manual
make logs # With Make
| Command | Description |
|---|---|
make |
Setup, build, launch and test all at once |
make setup |
Initialize environment and install uv |
make ensure_env |
Auto-create .env if missing |
make ensure_uv |
Install uv package manager if missing |
make build |
Build all Docker base images |
make start |
Start services with safe env loading and testing |
make stop |
Gracefully stop all services |
make restart |
Shortcut for stop + start |
make test |
Run full test suite |
make logs |
Stream container logs |
make clean |
Stop and remove orphan containers and volumes |
The RAGFlow sandbox is designed to balance security and usability, offering solid protection without compromising developer experience.
At its core, we use gVisor, a user-space kernel, to isolate code execution from the host system. gVisor intercepts and restricts syscalls, offering robust protection against container escapes and privilege escalations.
For users who need zero-trust-level syscall control, we support an additional seccomp profile. This feature restricts containers to only a predefined set of system calls, as specified in executor_manager/seccomp-profile-default.json.
⚠️ This feature is disabled by default to maintain compatibility and usability. Enabling it may cause compatibility issues with some dependencies.
.env file: SANDBOX_ENABLE_SECCOMP=true
executor_manager/seccomp-profile-default.json
This profile is passed to the container with:
--security-opt seccomp=/app/seccomp-profile-default.json
In addition to sandboxing, Python code is statically analyzed via AST (Abstract Syntax Tree) before execution. Potentially malicious code (e.g. file operations, subprocess calls, etc.) is rejected early, providing an extra layer of protection.
This security model strikes a balance between robust isolation and developer usability. While seccomp can be highly restrictive, our default setup aims to keep things usable for most developers — no obscure crashes or cryptic setup required.
Currently, the following languages are officially supported:
| Language | Priority |
|---|---|
| Python | High |
| Node.js | Medium |
To add Python dependencies, simply edit the following file:
sandbox_base_image/python/requirements.txt
Add any additional packages you need, one per line (just like a normal pip requirements file).
To add Node.js dependencies:
cd sandbox_base_image/nodejs
npm to install the desired packages. For example: npm install lodash
package.json and package-lock.json, and included in the Docker image when rebuilt.Contributions are welcome!