Files
nixos-core/scripts
kiskaadee 8356819f08 fix(gitops): harden compose validator against relative traversal, tenant escape, and breakouts
Closes containment and privilege escalation bypasses in validate_compose_security()
by enforcing strict path resolution, cross-tenant state isolation, and capability bans.

Previously, `validate_compose_security()` only inspected absolute host paths starting
with `/` or `~`, allowing relative traversal paths (`../../Core/nixos`) to skip
validation entirely. Furthermore, state root containment was evaluated against the
parent `~/var/lib/homelab`, allowing one workload to mount another workload's state,
and container breakouts (`cap_add`, `devices`, host namespaces, top-level `include`)
were not inspected.

- Resolve relative host paths against `allowed_root` and enforce containment strictly
  within either the workload root or the workload's dedicated state root
  (`~/var/lib/homelab/<app_name>/`), blocking cross-tenant state directory access.
- Reject container breakout capabilities (`cap_add`, `devices`), unconfined security
  profiles, host namespaces (`pid: host`, `ipc: host`, etc.), and top-level `include`.
- Reject `docker-compose.yml` symlinks that escape the workload root.
- Add 12 adversarial regression tests in `test_gitops_security.py`.
- Mark Pre-P4 compose hardening task completed in `todo.txt`.

Part of Pre-P4 Security Gate (Milestone P4 readiness).
2026-10-15 01:52:08 -05:00
..