Harden the agents: keep the token off the command line, lock down their files
Linux: the token went to curl as an argument, readable by any local user in the process list, and the reply was written to a fixed /tmp file that another user could replace with a symlink (the agent runs as root). The token now goes to curl on stdin, and the payload and reply live in a private mktemp directory that is removed afterwards. This also lifts the limit on a report's size that a command-line argument imposed. The systemd unit now runs with NoNewPrivileges, ProtectSystem=strict, PrivateTmp and similar restrictions (it still sees every process, which is how it names the program behind a port). Windows: the SYSTEM task's folder was left to inherit ProgramData's permissions. It now gets explicit ones: SYSTEM and Administrators only. Installed agents keep their own copy of the script, so each server needs the install one-liner re-run to pick this up. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c95d31d2d8
commit
047fcb403e
3 files changed
+62
-6
No files matched your search
@@ -88,6 +88,24 @@ Description=Report scheduled tasks to Homelab Manager
|
||||
Type=oneshot
|
||||
EnvironmentFile=$CONFIG_DIR/homelab-manager-agent.env
|
||||
ExecStart=$INSTALL_DIR/homelab-manager-agent.sh
|
||||
# The agent only reads (crontabs, timers, /proc, listening sockets) and makes one HTTPS request, but it runs as root. These
|
||||
# keep a bug in it, or in anything it parses, from being able to change the system. It still sees every process, which is
|
||||
# how it names the program behind each listening port. Directives an older systemd doesn't know are ignored.
|
||||
UMask=0077
|
||||
NoNewPrivileges=yes
|
||||
PrivateTmp=yes
|
||||
ProtectSystem=strict
|
||||
ProtectHome=read-only
|
||||
ProtectKernelTunables=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectKernelLogs=yes
|
||||
ProtectControlGroups=yes
|
||||
RestrictSUIDSGID=yes
|
||||
RestrictRealtime=yes
|
||||
RestrictNamespaces=yes
|
||||
LockPersonality=yes
|
||||
SystemCallArchitectures=native
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
|
||||
EOF
|
||||
|
||||
cat > "$SYSTEMD_DIR/homelab-manager-agent.timer" <<EOF
|
||||
|
||||
Reference in new issue
Block a user