vellaveto/crewai-sandbox-escape
0
CrewAI SandboxPython Escape PoC
Proof of concept demonstrating that SandboxPython in CrewAI's CodeInterpreterTool has an incomplete module blocklist, allowing full sandbox escape.
The Bug
SandboxPython blocks 9 modules (os, sys, subprocess, etc.) but leaves 15 dangerous modules importable: pathlib, socket, http.client, ctypes, io, pickle, multiprocessing, threading, asyncio, urllib.request, signal, code, xml.etree, zipfile, tarfile.
Running the PoC
pip install crewai-tools
python poc_sandbox_escape.pyThe PoC reproduces the exact SandboxPython class from source, verifies blocked modules are denied, then demonstrates 5 independent escapes:
- File read via
pathlib— reads/etc/hostname - DNS resolution via
socket— resolvesexample.com - HTTP request via
http.client— GETshttpbin.org/ip - File I/O via
io.open— bypasses blockedopenbuiltin - C calls via
ctypes— importsctypes.CDLL
Affected
- Package:
crewai-tools - File:
crewai_tools/tools/code_interpreter_tool/code_interpreter_tool.py - Class:
SandboxPython - Root cause: Blocklist (9 modules) instead of allowlist
CWE
CWE-693: Protection Mechanism Failure
