DIVE-1002: least-privilege agent isolation (standard-by-default + scoped admin)
Self-hosted AI team: Claude Code, Codex and more, from your phone
Brought to you by:
fivedive
Originally created by: lodar
Security fix (lodar-raised, Marcus-gated). New agents no longer get blanket superadmin sudo by default.
standard isolation (zero sudo), not admin. create_agent_user/write_agent_env fallbacks flipped to standard so no path silently grants root.admin, but the resolved tier is written into agents.json (never re-derived from create-order). Explicit --isolation always wins either way.ALL=(ALL) NOPASSWD: ALL with a visudo-validated allowlist: the 5dive CLI + non-paging systemctl start|stop|restart of 5dive-agent@* / 5dive-*.service. The three indirect root escapes are excluded:systemd-run * (arbitrary root) → replaced by 5dive agent restart <name> --defer, which runs systemd-run internally with a fixed command.journalctl * (pager !sh) → logs go through 5dive agent logs (--no-pager).systemctl status * (pager !sh) → only non-paging verbs granted.5dive crew now refuses EUID 0 (it execs agent-authored venv Python; reachable via sudo 5dive crew run it was a real admin→root hole).isolation:admin; their sudoers files are untouched. The scoped allowlist applies to new admins / fresh boxes.tests/agent_isolation_unit.sh (15/15): bootstrap resolution, visudo validity, all three escapes absent, crew root-refusal, restart --defer fixed-command, migration.shellcheck -S error clean.Existing admins keep their old full-sudo files (re-scoping a live agent's sudoers is a careful follow-up). The fresh-box least-privilege story is intact.
Security re-reviewed and passed by Marcus. Smoke (real Hetzner agent matrix) run separately.
🤖 Generated with Claude Code
Ticket changed by: lodar