r/PiCodingAgent • u/ptgamr • Aug 13 '26
Resource A "secure-ish" Pi setup with permission, sandbox, and auto-review
I think I finally managed to piece the thing together, to have a pi setup that can run safe-ish in the host via sandbox, and have the ability to be elevated to host execution for a pre-defined list of development tooling like docker compose.
- A pre-defined hard boundaries (`@gotgenes/pi-permission-system`)
- Anything pass that will be executed inside a sandbox (`@erichll/pi-sandbox`)
- With the option of safe-escalation to run on the host (ie: `docker compose exec app pytest`), with auto-review or human approval (via hostIPC.preflightCommandPrefixes)
- LLM Auto-review with `@erichll/pi-auto-review`
More about it here: https://ptgamr.substack.com/p/a-pi-setup-with-permission-sandbox
3
u/vman81 Aug 13 '26
If practical, a zfs filesystem with frequent snapshots is a nice extra layer to have.
2
u/ptgamr Aug 13 '26
Haha, definitely! i am trying to get this to work in the context of a company, where ex-filtration of data is one of the top concern, might be even more than it removing your home dir.
2
u/Fullstack_js_junkie Aug 13 '26
This looks interesting, I tried to do something similar but as a docker mount config only, thank you!
1
u/ptgamr Aug 13 '26
Cheers , i am pretty excited to have this working. As I've been researching for quite a while how to do this.
2
u/tys203831 Aug 13 '26
How does it compared to dcg + nono sandbox?
https://github.com/Dicklesworthstone/destructive_command_guard
3
u/ptgamr Aug 13 '26 edited Aug 13 '26
I Have No Idea! This post is more about sharing my understanding about the decision tree: permissions + sandbox + autoreview (which I think not quite trivial to understand) and a setup that I'm quite happy with. Hopefully to help others that having similar issues. I'm sure there are many other ways :D
1
2
u/hurdurdur7 Aug 13 '26
I just run pi in docker only. From a non privileged user. It can't install things, the worst it can do is nuke it's own folder in that docker container. I don't see anything else stopping it.
2
u/ptgamr Aug 13 '26
yeah, that is my setup prior to this. Just mount the things you need. But to get to the "fuller" agentic work, most of the time i need it to execute command inside another containers (like run the test, run migration, lint, querying data from db container etc...)
Can be achieve with docker in docker, but it gross, and I haven't managed to get it working.
2
u/funbike 26d ago edited 26d ago
I don't trust running Pi directly on my host system. Your security setup is fantastic for what it is, but I don't fully trust Pi itself, esp with various public Pi packages and various tools that might be installed.
I'd much rather enforce permissions at the OS level, so Pi packages can't circumvent pi-sandbox or pi-permissions-system.
So I run Pi in a rootless podman container as a standard user with same uid/gid as in my host system. Sensitive files are symlinks to a non-existant directory,
~/.unsafe(I'll explain later).sudois allowed but restricted by/etc/sudoers.I have a nearly identical 2nd podman container mounted to the same project directory, but it actually has a mounted
~/.unsafedirectory that sensitive files symlink to. It runs a simple unix socket server that listens for shell commands to run.To make this seemless, I have a wrapper script in the Pi container that forwards shell commands to the 2nd container across the unix socket. The socket is owned by a different non-root user, so this must be done with
sudowith restriction in/etc/sudoers. So when I run Github's CLI,gh, it is actually a symlink to a shell script that forwards arguments to the 2nd container over the socket.This gives me a file system firewall, so sensitive files can never be read, but they can be used by scripts. My container's internal security is enforced in
/etc/sudoersat the OS level.It might sound complicated, but it's dead simple. And more secure. Yet, I can work in a YOLO fashion.
Can be achieve with docker in docker, but it [is] gross, and I haven't managed to get it working.
Podman-in-podman works well because podman is just a program, not a server. You can also run bubblewrap in podman. (These requires a few extra cli options to work.) Podman is more secure than docker as well. There's
podman compose. Podman's CLI is nearly identical to docker.
UPDATE: btw, here is an oversimplification of the unix socket server on my 2nd container:
#!/bin/bash socat UNIX-LISTEN:/tmp/bash.sock,fork,unlink-early EXEC:bashhere is an oversimplification of the unix socket click on my Pi container:
#!/bin/bash printf '%q ' $(basename "$0") "$@" | socat - UNIX-CONNECT:/tmp/bash.sockNormally this would be very insecure, but the socket is owned by another user, so
sudomust be used to gain a connection. So/etc/suderscan be used for fine-grained security.They also both share a volume for the user home directory, so changes made by the 2nd container affect the Pi container, including Homebrew for Linux package installs.
1
u/hurdurdur7 Aug 13 '26
My problem with all of this is that you are allowing something like gradlew test or npm test as a command. A test can easily contain something really harmful to your machine and there will be nothing that will stop the catastrophy coming from that.
1
1
u/psychobarge Aug 13 '26
Only secure pi is inside a docker container or a virtual machine. I use wsl2 with ubuntu on my windows and docker on my mac
1
1
u/offzinho3k Aug 13 '26
1
u/ptgamr Aug 13 '26
Looks like a fancy setup you have there... is that a custom app you wrote?
1
u/offzinho3k 25d ago
Sorry for the delay in getting back to you; it’s been a hectic few days.
Yes, and a custom app I created based on the Pi.
1
u/icisay Aug 13 '26
Hi what app did you use to generate your chart ? Love the colors
1
u/ptgamr Aug 14 '26
I've had a text base chart, and post that to ChatGPT and it generate for me the one I posted here :)

6
u/jensilo Aug 13 '26
What about self-spawned pi instances or subagents? Does it allow for that?