Skip to content

Commit c46f9d0

Browse files
committed
feat: add /proc hidepid=2 isolation for process visibility
- setup.sh creates procview group, adds admin user, mounts /proc with hidepid=2,gid=<procview_gid> - Persisted in /etc/fstab for reboots - hornet_agent can only see its own processes; admin retains full visibility - security-audit.sh checks for hidepid=2 mount - Also fixes git identity in setup.sh (was hornet-fw, now Ben Vinegar)
1 parent 28b144e commit c46f9d0

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

bin/security-audit.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,18 @@ if [ -d "$HORNET_HOME/.pi/agent/sessions" ]; then
211211
fi
212212
echo ""
213213

214+
# ── Process Isolation ─────────────────────────────────────────────────────────
215+
216+
echo "Process Isolation"
217+
proc_mount=$(grep '^proc /proc' /proc/mounts 2>/dev/null || true)
218+
if echo "$proc_mount" | grep -q 'hidepid=2'; then
219+
ok "/proc mounted with hidepid=2 (hornet_agent can only see own processes)"
220+
else
221+
finding "WARN" "/proc not mounted with hidepid=2" \
222+
"hornet_agent can see all system processes — run setup.sh or: sudo mount -o remount,hidepid=2,gid=<procview_gid> /proc"
223+
fi
224+
echo ""
225+
214226
# ── Network ──────────────────────────────────────────────────────────────────
215227

216228
echo "Network"

setup.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# 7. Symlinks pi config from the repo
1717
# 8. Installs Slack bridge dependencies
1818
# 9. Sets up firewall and makes it persistent
19+
# 10. Enables /proc hidepid isolation (process visibility)
1920
#
2021
# After running, you still need to:
2122
# - Set the hornet_agent password: sudo passwd hornet_agent
@@ -87,8 +88,8 @@ sudo -u hornet_agent bash -c "
8788

8889
echo "=== Configuring git identity ==="
8990
sudo -u hornet_agent bash -c '
90-
git config --global user.name "hornet-fw"
91-
git config --global user.email "hornet@modem.codes"
91+
git config --global user.name "Ben Vinegar"
92+
git config --global user.email "ben@benv.ca"
9293
git config --global init.defaultBranch main
9394
'
9495

@@ -165,6 +166,32 @@ systemctl daemon-reload
165166
systemctl enable hornet-firewall
166167
echo "Firewall will be restored on boot via systemd"
167168

169+
echo "=== Setting up /proc isolation (hidepid) ==="
170+
# Create a group whose members can still see all processes.
171+
# The admin user is added; hornet_agent is NOT — it only sees its own processes.
172+
PROC_GID_GROUP="procview"
173+
if ! getent group "$PROC_GID_GROUP" &>/dev/null; then
174+
groupadd "$PROC_GID_GROUP"
175+
echo "Created group: $PROC_GID_GROUP"
176+
fi
177+
usermod -aG "$PROC_GID_GROUP" "$ADMIN_USER"
178+
PROC_GID=$(getent group "$PROC_GID_GROUP" | cut -d: -f3)
179+
180+
# Apply immediately
181+
mount -o remount,hidepid=2,gid="$PROC_GID" /proc
182+
echo "Remounted /proc with hidepid=2,gid=$PROC_GID"
183+
184+
# Persist in /etc/fstab (idempotent)
185+
if grep -q '^proc\s\+/proc' /etc/fstab; then
186+
# Update existing proc line
187+
sed -i "s|^proc\s\+/proc\s\+proc\s\+.*|proc /proc proc defaults,hidepid=2,gid=$PROC_GID 0 0|" /etc/fstab
188+
echo "Updated existing /proc entry in /etc/fstab"
189+
else
190+
echo "proc /proc proc defaults,hidepid=2,gid=$PROC_GID 0 0" >> /etc/fstab
191+
echo "Added /proc entry to /etc/fstab"
192+
fi
193+
echo "Process isolation: hornet_agent can only see its own processes"
194+
168195
echo "=== Hardening permissions ==="
169196
sudo -u hornet_agent "$REPO_DIR/bin/harden-permissions.sh"
170197

@@ -184,6 +211,7 @@ echo " SLACK_APP_TOKEN=xapp-..."
184211
echo " SLACK_ALLOWED_USERS=U01234,U56789 (REQUIRED — bridge refuses to start without this)"
185212
echo " 3. Add SSH key to hornet-fw GitHub account"
186213
echo " 4. Log out and back in for group membership to take effect"
214+
echo " (both hornet_agent group and procview group)"
187215
echo " 5. Launch: sudo -u hornet_agent $HORNET_HOME/hornet/start.sh"
188216
echo ""
189217
echo "To verify security posture:"

0 commit comments

Comments
 (0)