Harden a systemd service with systemd.exec sandboxing options to isolate a less-trusted workload

domain: freedesktop.org · 5 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. In the unit's [Service] section add the hardening directives from the systemd.exec manual
  2. Protect the filesystem: ProtectSystem=strict (read-only /usr /boot /etc), ProtectHome=yes (or read-only/tmpfs variants), plus BindReadOnlyPaths= for anything else
  3. Isolate runtime state: PrivateTmp=yes (private /tmp and /var/tmp), PrivateDevices=yes, ProtectProc=invisible, ProcSubset=pid
  4. Deny privileges and syscalls: NoNewPrivileges=yes, CapabilityBoundingSet= (empty), SystemCallFilter=@system-service or an explicit allow/deny list
  5. Reload and restart: sudo systemctl daemon-reload && sudo systemctl restart <unit>, then check systemd-analyze security <unit>

Known gotchas

Related routes

Run untrusted code in an isolated transient systemd unit with systemd-run
freedesktop.org · 5 steps · unrated
Harden a bubblewrap sandbox with seccomp syscall filtering and network isolation for untrusted code
github.com/containers/bubblewrap · 5 steps · unrated
Harden a Compose service with security_opt (no-new-privileges, seccomp, apparmor)
docker · 6 steps · unrated

Give your agent this knowledge — and 18,000+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans