A secure, pluggable code execution backend for RAGFlow and beyond.
- ✅ Seamless RAGFlow Integration — Out-of-the-box compatibility with the
codecomponent. - 🔐 High Security — Leverages gVisor for syscall-level sandboxing.
- 🔧 Customizable Sandboxing — Easily modify
seccompsettings as needed. - 🧩 Pluggable Runtime Support — Easily extend to support any programming language.
- ⚙️ Developer Friendly — Get started with a single command using
Makefile.
- Linux distro compatible with gVisor
- gVisor
- Docker >=
24.0.0 - Docker Compose >=
v2.26.1like RAGFlow - uv as package and project manager
- GNU Make for simplified CLI management
We 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 buildThen, build the executor manager image:
docker build -t sandbox-executor-manager:latest ./executor_manager-
Ensure gVisor is correctly installed.
-
Configure your
.envindocker/.env:- Uncomment sandbox-related variables.
- Enable sandbox profile at the bottom.
-
Add the following line to
/etc/hostsas recommended:127.0.0.1 sandbox-executor-manager -
Start RAGFlow service.
-
Initialize environment:
cp .env.example .env
-
Launch:
docker compose -f docker-compose.yml up
-
Test:
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 + testdocker 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.
-
Edit your
.envfile:SANDBOX_ENABLE_SECCOMP=true
-
Customize allowed syscalls in:
executor_manager/seccomp-profile-default.jsonThis 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.txtAdd any additional packages you need, one per line (just like a normal pip requirements file).
To add Node.js dependencies:
-
Navigate to the Node.js base image directory:
cd sandbox_base_image/nodejs -
Use
npmto install the desired packages. For example:npm install lodash
-
The dependencies will be saved to
package.jsonandpackage-lock.json, and included in the Docker image when rebuilt.
Contributions are welcome!