agent-command-sandbox.sh
A sandbox wrapper that constrains which commands the autonomous agents are allowed to execute.
Note
Live script from my home-lab server. Tokens, IDs, phone numbers and other secrets have been replaced with
placeholders like
<WHATSAPP_GROUP_ID> — everything else is the real, running code.
#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -ne 1 ]; then
echo "Usage: agent-command-sandbox.sh <command>" >&2
exit 2
fi
command_text=$1
exec bwrap \
--ro-bind / / \
--remount-ro / \
--ro-bind /home/lanky /home/lanky \
--remount-ro /home/lanky \
--ro-bind /mnt/nas /mnt/nas \
--remount-ro /mnt/nas \
--ro-bind /mnt/jelly /mnt/jelly \
--remount-ro /mnt/jelly \
--tmpfs /tmp \
--tmpfs /run \
--dev /dev \
--proc /proc \
--unshare-all \
--share-net \
--unshare-user \
--disable-userns \
--new-session \
--die-with-parent \
--clearenv \
--setenv HOME /tmp \
--setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
--setenv LANG C.UTF-8 \
--chdir /tmp \
/bin/bash --noprofile --norc -lc "$command_text"