BashBox: A Sandboxed Bash Interpreter for AI Agents in PHP
Execute shell commands and bash scripts generated by autonomous AI agents securely within isolated WebAssembly sandboxes in PHP.
BashBox: A Sandboxed Bash Interpreter for AI Agents in PHP
Giving autonomous AI agents terminal access is powerful for code generation, workspace indexing, and data transforms. However, executing arbitrary bash commands on a host server poses severe security risks.
Secure Wasm Sandboxing
BashBox solves this by running an entire virtualized Linux userspace compiled to WebAssembly directly inside PHP, completely decoupled from host disk, network, and process tables:
use BashBox\Sandbox;
$sandbox = Sandbox::create()
->withFilesystem([
'data.csv' => file_get_contents('data.csv'),
])
->withTimeout(5);
$result = $sandbox->run('cat data.csv | awk -F"," \'{print $2}\' | sort | uniq -c');
echo $result->output();
Even if an agent executes dangerous commands like rm -rf /, the blast radius is strictly confined to the in-memory virtual container.