Sandbox backends provide isolated command execution environments with explicit shell control to prevent injection attacks while enabling shell features when needed.Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Quick Start
How It Works
| Backend | Use Case | Security Level |
|---|---|---|
SubprocessSandbox | Local development, scripts | Medium (OS-level isolation) |
DockerSandbox | Production, untrusted code | High (container isolation) |
SSHSandbox | Remote execution | High (network isolation) |
Configuration Options
Shell Parameter Control
- shell=False (Default)
- shell=True (Opt-in)
shlex.split().Decision Guide
| Use Case | Recommended shell Value |
|---|---|
| Running a single executable with arguments | False |
Pipelines (grep | sort) | True |
| Globs and env-var expansion | True |
| Untrusted / model-generated commands | False |
Common Patterns
Backend Selection
- Development
- Production
- Remote
Safe Data Processing
Resource Limits
Best Practices
Always use shell=False for untrusted input
Always use shell=False for untrusted input
Model-generated commands or user input should never use
shell=True to prevent injection attacks. The default shell=False provides automatic protection.Quote arguments when building shell commands
Quote arguments when building shell commands
If you must use
shell=True, quote all dynamic arguments with shlex.quote():Prefer list form for complex commands
Prefer list form for complex commands
Using argument lists avoids shell parsing entirely:
Use appropriate backend for your security needs
Use appropriate backend for your security needs
Choose the sandbox backend based on your isolation requirements:
- Development:
SubprocessSandboxfor speed and convenience - Production:
DockerSandboxfor container-level isolation - Remote:
SSHSandboxfor network-isolated execution - High Security: Always use Docker or SSH backends with
shell=False
Related
Resource Limits
Configure timeouts and memory limits for sandbox execution
Thread Safety
Understanding thread-safe operations across PraisonAI components

