mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-11-29 15:31:53 +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
|
|
@ -252,6 +252,7 @@ func main() {
|
|||
if m, err := pods.Detect(filepath.Join(dataDir, "users")); err == nil {
|
||||
a.pods = m
|
||||
log.Info("pods enabled", "engine", m.Engine())
|
||||
go a.reapBannedPods()
|
||||
} else {
|
||||
log.Warn("pods disabled", "reason", err)
|
||||
}
|
||||
|
|
@ -2461,3 +2462,28 @@ func (a *app) handleHealth(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
_, _ = w.Write([]byte(`{"status":"ok","db":"ok"}`))
|
||||
}
|
||||
|
||||
// reapBannedPods removes the pod of every banned member, at start and every
|
||||
// two minutes. Banning blocks new sessions, but a pod is a long-running
|
||||
// container (--restart unless-stopped) and shells left inside it keep
|
||||
// running; on 2026-11-20 a banned member's pod had been up for four days.
|
||||
func (a *app) reapBannedPods() {
|
||||
reap := func() {
|
||||
users, err := a.st.ListUsers(1_000_000)
|
||||
if err != nil {
|
||||
log.Warn("reap banned pods: list users", "err", err)
|
||||
return
|
||||
}
|
||||
for _, u := range users {
|
||||
if u.Banned && a.pods.Remove(u.Name) {
|
||||
log.Info("removed pod of banned member", "user", u.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
reap()
|
||||
t := time.NewTicker(2 * time.Minute)
|
||||
defer t.Stop()
|
||||
for range t.C {
|
||||
reap()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue