This commit is contained in:
2026-09-22 23:37:05 +03:00
parent cf1c31eb2a
commit 0fc35589e6
25 changed files with 2616 additions and 245 deletions

View File

@@ -19,7 +19,7 @@ CSRF header on mutations. Passwords use Argon2id.
| Request flooding | request timeouts, concurrency semaphore, token buckets, reverse-proxy limits |
| Command injection | no command strings; executable and subcommands are constants; service names are allow-listed |
| Privilege escalation | unprivileged user, systemd sandbox, no capabilities, write privileges opt-in and narrow |
| Accidental firewall lockout | v1 is read-only; future mutations require local, crash-safe confirm-or-rollback |
| Accidental firewall damage | only dedicated chains are mutable; every change snapshots, restores on error, and persists only after success |
| Disk/log exhaustion | journald only, no metric spool, PostgreSQL retention, bounded body/audit fields |
| Observability token theft | independent file secret, constant-time verification, per-source limiting, no agent credentials in Grafana |
| Expensive dashboard queries | fixed metric set, restricted selectors, 31-day ranges, point/row/result caps |
@@ -37,13 +37,18 @@ the file, restart the agent, then update its control-plane Docker secret and
restart the backend. Keep the overlap window short; the agent intentionally
accepts one token. Never pass the token on a command line.
## Firewall safety design (future helper)
## Privileged helper and firewall safety
The future root helper owns only `table inet vps_control`. It writes a bounded
snapshot (maximum five), fsyncs a pending transaction with a monotonic deadline,
applies a complete validated table, and starts an independent rollback timer.
Only an authenticated confirmation commits. On restart it rolls back any pending
transaction before accepting a new one. Unknown tables/chains remain read-only.
The HTTP daemon remains unprivileged. A socket-activated, one-request root helper
accepts only typed operations from the `vps-agent` Unix account. Firewall writes
are restricted to `VPS_CONTROL_INPUT` and `VPS_CONTROL_RATE`; external rules are
always read-only. Before a mutation the helper stores a bounded `iptables-save`
snapshot and arms an independent systemd rollback timer. The backend confirms
the transaction only after reconnecting to the agent; without confirmation the
snapshot is restored and persisted. Immediate command failures also restore it.
Interfaces, source CIDRs, ports, services, packages and Fail2Ban jails must all
match local configuration allow-lists. Service installation uses a fixed
`apt-get` argv in a time-bounded transient systemd unit.
## Operational logging