Root remediation: backup timer trusts agent-owned restic and .env #62

Closed
opened 2026-11-20 01:10:10 +00:00 by inference-bot · 2 comments
Owner

Root-only remediation required on the agent host. The nightly backup unit runs root-owned /usr/local/sbin/agent-backup, but that script still resolves restic from /usr/local/bin/restic (owned by ubuntu) and sources /home/ubuntu/.hermes/.env with /home/ubuntu/.local/bin on PATH. An agent-writable binary or env is therefore root code execution through the backup timer.

Required root commands:

  • chown root:root /usr/local/bin/restic
  • remove /home/ubuntu/.local/bin from the root script's PATH
  • stop sourcing /home/ubuntu/.hermes/.env
  • remove the Hermes-python pip list diagnostic
  • systemctl daemon-reload

The restricted sudo policy deliberately does not grant these. The daily watchdog (82130f968506) alerts if the conditions regress. Until fixed, treat the backup timer as privileged.

Root-only remediation required on the agent host. The nightly backup unit runs root-owned `/usr/local/sbin/agent-backup`, but that script still resolves `restic` from `/usr/local/bin/restic` (owned by `ubuntu`) and sources `/home/ubuntu/.hermes/.env` with `/home/ubuntu/.local/bin` on `PATH`. An agent-writable binary or env is therefore root code execution through the backup timer. Required root commands: - `chown root:root /usr/local/bin/restic` - remove `/home/ubuntu/.local/bin` from the root script's `PATH` - stop sourcing `/home/ubuntu/.hermes/.env` - remove the Hermes-python `pip list` diagnostic - `systemctl daemon-reload` The restricted sudo policy deliberately does not grant these. The daily watchdog (`82130f968506`) alerts if the conditions regress. Until fixed, treat the backup timer as privileged.
inference-admin added the Infrastructure label 2026-11-22 00:26:38 +00:00
Author
Owner

Status 2026-11-22 — four of the five items are already satisfied on the host; one remains, and it is root-only.

Verified now:

  • /usr/local/bin/restic is root:root, mode 755.
  • The script's PATH is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin — no /home/ubuntu/.local/bin.
  • It sources /etc/agent-backup.env only; there is no reference to the agent's .env.
  • The unit's drop-in points ExecStart at /usr/local/sbin/agent-backup, itself root:root 755, so no daemon-reload is outstanding.

Remaining: the manifest step still runs "$HERMES_DIR/tools/python-…/bin/python3" -m pip list as root. That is an agent-writable binary executed by a root unit — the same class of path this issue exists to remove, and the current watchdog did not catch it.

I prepared the fix at /tmp/agent-backup.proposed (mirrored at ~/.hermes/pending/agent-backup.proposed): the manifest's pip inventory is kept but now runs as ubuntu via runuser -u ubuntu --, so root no longer executes the agent-owned interpreter. bash -n clean; the root-trust watchdog accepts this form and still flags a direct root execution. It cannot be installed from the agent account (ubuntu): the restricted sudo policy deliberately does not grant install. The host's root-capable admin account is the one that runs it.

Run from the host's root-capable admin account:

install -o root -g root -m 755 /tmp/agent-backup.proposed /usr/local/sbin/agent-backup

then optionally systemctl start agent-backup.service to confirm the nightly path still runs.

I also extended check_root_trust.py to flag any root backup step that executes a binary under .hermes/tools, so this cannot regress silently. It reports the current finding (expected) and passes against the proposed copy.

**Status 2026-11-22 — four of the five items are already satisfied on the host; one remains, and it is root-only.** Verified now: - `/usr/local/bin/restic` is `root:root`, mode 755. - The script's `PATH` is `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin` — no `/home/ubuntu/.local/bin`. - It sources `/etc/agent-backup.env` only; there is no reference to the agent's `.env`. - The unit's drop-in points `ExecStart` at `/usr/local/sbin/agent-backup`, itself `root:root` 755, so no `daemon-reload` is outstanding. **Remaining:** the manifest step still runs `"$HERMES_DIR/tools/python-…/bin/python3" -m pip list` as root. That is an agent-writable binary executed by a root unit — the same class of path this issue exists to remove, and the current watchdog did not catch it. I prepared the fix at `/tmp/agent-backup.proposed` (mirrored at `~/.hermes/pending/agent-backup.proposed`): the manifest's pip inventory is kept but now runs as `ubuntu` via `runuser -u ubuntu --`, so root no longer executes the agent-owned interpreter. `bash -n` clean; the root-trust watchdog accepts this form and still flags a direct root execution. It cannot be installed from the agent account (`ubuntu`): the restricted sudo policy deliberately does not grant `install`. The host's root-capable admin account is the one that runs it. Run from the host's root-capable admin account: ``` install -o root -g root -m 755 /tmp/agent-backup.proposed /usr/local/sbin/agent-backup ``` then optionally `systemctl start agent-backup.service` to confirm the nightly path still runs. I also extended `check_root_trust.py` to flag any root backup step that executes a binary under `.hermes/tools`, so this cannot regress silently. It reports the current finding (expected) and passes against the proposed copy.
Author
Owner

Fixed and verified 2026-11-22.

  • Installed from the root-capable admin account: /usr/local/sbin/agent-backup is root:root 755, md5 c46ad15cef4414ac225f34549ed1d96a.
  • The manifest's pip inventory is kept, but it no longer executes the agent-owned interpreter as root: it runs as ubuntu via runuser -u ubuntu --.
  • Exercised through the unit: systemctl start agent-backup.service → Result=success, snapshot 8c87c888 saved, and manifest.txt still carries the pip (hermes python) section.
  • check_root_trust.py now prints nothing; it accepts the runuser form and still flags a direct root execution of an agent-owned tool binary.

One related hardening item remains outside this issue's scope: root still opens backup.lock, backup-last.log and the staged SQLite paths inside directories the ubuntu user owns, so a symlink swap there is a root file-write primitive. I will track that separately rather than reopen this one.

**Fixed and verified 2026-11-22.** - Installed from the root-capable admin account: `/usr/local/sbin/agent-backup` is `root:root 755`, md5 `c46ad15cef4414ac225f34549ed1d96a`. - The manifest's pip inventory is kept, but it no longer executes the agent-owned interpreter as root: it runs as `ubuntu` via `runuser -u ubuntu --`. - Exercised through the unit: `systemctl start agent-backup.service` → `Result=success`, snapshot `8c87c888` saved, and `manifest.txt` still carries the `pip (hermes python)` section. - `check_root_trust.py` now prints nothing; it accepts the `runuser` form and still flags a direct root execution of an agent-owned tool binary. One related hardening item remains outside this issue's scope: root still opens `backup.lock`, `backup-last.log` and the staged SQLite paths inside directories the `ubuntu` user owns, so a symlink swap there is a root file-write primitive. I will track that separately rather than reopen this one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: co-op/support#62