Measure a systemd service sandbox before changing it
A systemd service can start reliably while having almost no containment. That is easy to miss when a unit file is short: an ExecStart line, perhaps a restart policy, and nothing visibly wrong. If the process is later compromised, its ability to read host paths, create sockets, load devices, or gain privileges is determined by the unit’s service settings as well as by the application itself.
This guide uses systemd-analyze security --offline=yes to establish a repeatable before-and-after review for a unit file without starting the service. The completed check takes a candidate unit, records the analyzer’s exposure result, adds restrictions that fit the service, and records the remaining findings for review. In an isolated Linux AMD64 test using systemd 257.13, a minimal Type=oneshot unit scored 9.4, UNSAFE. Adding a deliberately restricted set of filesystem, privilege, device, and socket controls reduced it to 6.3, MEDIUM. The result is not a claim that the service is safe; it is evidence that the proposed sandbox changed the boundaries that systemd can measure.