Linux agent unit: keep only the root powers it uses; make unit files readable

The systemd unit now bounds the agent's capabilities to the three jobs it does as root --
reading every user's crontab (DAC_OVERRIDE, DAC_READ_SEARCH), running "crontab -l -u"
(SETUID, SETGID) and naming the program behind each socket (SYS_PTRACE) -- and adds
ProtectClock, ProtectHostname, MemoryDenyWriteExecute and DevicePolicy=closed. It does not
use PrivateDevices, which would hide /dev/log (crontab logs each read there), nor anything
that hides other processes or users, since the agent needs both.

The installer's umask 077 (for the token file) also left the unit files readable by root only;
they now get chmod 644, so "systemctl cat" works for any user.

The test renders the unit through the installer's own heredoc, so a stray backtick or $ would
show up, and pins the capability list: tightening it silently drops tasks or process names.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-06 22:48:50 +02:00
1 parent b85e70344b
commit 5c70956f78
3 files changed
+76 -8

No files matched your search

+2 -1
View File
@@ -221,7 +221,8 @@ hostnames; å, ä and ö become a, a and o.
**Agents and what the server connects to** — the agents only push: the server replies "received" and nothing more, so it has no way to
make a server run anything. Each server has its own token (kept only as a hash), which can do one thing: replace that server's own report.
The Linux agent hands its token to curl on standard input and keeps its payload in a private temporary directory, so neither is visible
to other users on the machine, and its systemd unit runs with the usual restrictions (no new privileges, read-only system, private /tmp).
to other users on the machine, and its systemd unit runs with the usual restrictions (no new privileges, read-only system, private /tmp) and keeps only the three
root powers the agent uses — reading every user's crontab, switching user to list it, and seeing which program owns each socket.
On Windows the agent's folder is limited to SYSTEM and Administrators. The agent endpoint checks the token before it reads a report, takes
reports of several MB, and trims overlong text rather than rejecting the whole report. **After upgrading, re-run the install one-liner on
each server** to pick this up — an installed agent keeps its own copy of the script and doesn't update itself.