Security: Unsandboxed exec()/eval() in PythonExecutor with trivially bypassable filter
The `GenericRuntime` class in `qwen_agent/tools/python_executor.py` executes code via `exec()` and `eval()` with no sandboxing. The only input validation is two regex checks blocking `input()` and `os.system()` — all other dangerous operations remain available.
The filter is trivially bypassable:
- `__import__('os').popen('command')` — not filtered
- `subprocess` module — not filtered
- `open()` for file access — not filtered
- `getattr(__import__('os'), 'sys'+'tem')('cmd')` — string concatenation bypasses the `os.system` regex
When the `PythonExecutor` tool is enabled, an attacker can achieve arbitrary code execution on the host through prompt injection. While the tool is not registered by default and the docstring warns against production use, no sandboxed alternative is provided.
All versions up to and including 0.0.34 are affected.
**Recommendation:** Replace `exec()` with a sandboxed execution environment (Docker, E2B, WebAssembly, etc.), or at minimum implement AST-based validation and restrict `__builtins__`.
This project does not currently have a security policy or SECURITY.md. We recommend enabling GitHub Security Advisories so that vulnerabilities can be reported privately.
Credit: @CFionaBF
0 条评论