Sandpi - Bash script for running isolated container running Pi in current directory
Threat model. Long story short
I don't trust the harness nor LLMs. Many times I've encountered that I ran Pi, Oh My Pi or OpenCode in a project directory and it changed files in my dotfiles, ~/.local or put a bunch of files in my /tmp directory. I don't like it and I have no way to trust my workflow to not ruin my system the more I am using it.
So I created super dead-simple bash script sandpi to wrap Pi in a podman container sharing only:
- current directory
~/.sandpi/pi-agentshared between all executions (it can break it, I don't care - just symlink it to your dotfiles repo and version-control it)~/.agentsread-only to share all your skills, I added it for convenience
I hardcoded some limits just for the sake of peace of mind: 2 CPUs, 4 GB RAM, all capabilities dropped, no-new-privileges. Optionally, a KVM microVM boundary via krun - slower start, separate guest kernel (for some additional security if there are malicious automations for container escapes).
Try it
git clone https://github.com/intpl/sandpi ~/.sandpi
ln -sfn ~/.sandpi/sandpi ~/.local/bin/sandpi
sandpi --sandpi-build
cd ~/code/some-project
sandpi # interactive TUI
sandpi -p "summarise this repo"
sandpi --sandpi-throwaway # overlay the workspace, write nothing back
The launcher takes the current directory, starts the container with it mounted, and hands the terminal to Pi. No config file to edit between projects - the project is whatever directory you were standing in.
Throwaway mode
The workspace is mounted as an overlay instead of a bind mount, so writes land in the container layer and are discarded with it. Whatever you do inside your current directory - is lost.
What it's not.
It's not security against malicious code. It's only some limited safety net against stupidity and recklessness of a model or harness.
- The workspace is mounted read-write, so anything written there - git hooks,
package.jsonscripts,.envrc- runs on your host next time. This is a risk for malicious behaviour (supply chain attacks etc that will go to your host) - Networking is open. Other devices on LAN too.
- Provider API keys are in the environment. Set limits in your provider dashboard, use different API key.
- Without krun, the container shares your kernel. Container escapes are possible and more probable as we go to agentic-automated mass attacks.
- It does not make you safe if an attacker is already inside the sandbox.
Repo: github.com/intpl/sandpi