mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-12-01 01:14:47 +00:00
security: pod egress guard + remove banned members' pods (#172)
Member pods egress through pasta as the host. A pod could reach every 0.0.0.0 listener on the BBS host (ufw does not filter local delivery; pasta maps the host at 169.254.1.2) and could open SSH to other fleet servers from the BBS IP. On 2026-11-19 an attacker with a pod did both. - deploy/podguard.sh: nftables table matched by socket cgroup (the service user's slice), so the agentbbs daemon is unaffected. Pods may only use the host's public ports + DNS; servers listed in /etc/agentbbs/podguard.env are dropped. Loaded after user@<uid> and every 5 minutes (nft binds the cgroup id at load time). - pods.Manager.Remove + reapBannedPods: a banned member's pod is removed at start and every 2 minutes (it previously kept running for days). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
388360012c
commit
e68938fa0e
4 changed files with 134 additions and 0 deletions
35
setup.sh
35
setup.sh
|
|
@ -418,6 +418,41 @@ if [ -f "$SRC_DIR/pods/Containerfile" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Pod egress guard: member pods must not reach this host's private services or
|
||||
# the operator's other servers (see deploy/podguard.sh). Applied now, after the
|
||||
# service user's systemd instance starts, and every 5 minutes.
|
||||
install -m 0755 "$SRC_DIR/deploy/podguard.sh" /usr/local/sbin/agentbbs-podguard
|
||||
cat > /etc/systemd/system/agentbbs-podguard.service <<UNIT
|
||||
[Unit]
|
||||
Description=AgentBBS pod egress guard (nftables)
|
||||
After=user@${SVC_UID}.service nftables.service
|
||||
Wants=user@${SVC_UID}.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Environment=SVC_USER=${SVC_USER}
|
||||
ExecStart=/usr/local/sbin/agentbbs-podguard
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target user@${SVC_UID}.service
|
||||
UNIT
|
||||
cat > /etc/systemd/system/agentbbs-podguard.timer <<UNIT
|
||||
[Unit]
|
||||
Description=Re-apply the AgentBBS pod egress guard
|
||||
|
||||
[Timer]
|
||||
OnBootSec=2min
|
||||
OnUnitActiveSec=5min
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
UNIT
|
||||
systemctl daemon-reload
|
||||
systemctl enable agentbbs-podguard.service agentbbs-podguard.timer >/dev/null 2>&1 || true
|
||||
systemctl start agentbbs-podguard.timer >/dev/null 2>&1 || true
|
||||
systemctl start agentbbs-podguard.service \
|
||||
|| warn "pod egress guard failed to load — check: journalctl -u agentbbs-podguard -n20"
|
||||
|
||||
# ---- 6. environment file ---------------------------------------------------
|
||||
ENV_DIR=/etc/agentbbs
|
||||
install -d -m 0750 "$ENV_DIR"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue