1. Paste your unit
Name each block like its real path. A block named app.service.d/override.conf is merged into app.service after it, drop-ins in file-name order, as systemd does.
Paste at least one .service file above and click Check.
Findings
| File : Line | Type | Risk | Fix |
|---|
Prefer a CLI, or want this in your own CI?
Same logic, zero dependencies, one file:
python3 check.py # scan .service files under the current directory
python3 check.py /etc/systemd/system/ # a whole directory, drop-ins merged
python3 check.py app.service --drop-in # also print a starter hardening drop-in
python3 check.py --format json # machine-readable
python3 check.py --fail-on-risk # exit 2 on any medium or high finding
Get check.py from the repo: stdlib only, nothing to install, no network calls, and it never runs systemctl. It reads *.service and NAME.service.d/*.conf and skips .git, node_modules and build folders.
Common questions
How do I harden a systemd service?
Run it as an unprivileged user (User= or DynamicUser=yes), then add sandbox settings in a drop-in with systemctl edit: NoNewPrivileges=yes, ProtectSystem=strict with ReadWritePaths= for what it writes, ProtectHome=yes, PrivateTmp=yes, PrivateDevices=yes, the ProtectKernel settings, SystemCallFilter=@system-service and RestrictAddressFamilies=. Restart the service and read its journal after each change, and loosen any setting that breaks it.
Is it safe to put a password in Environment= in a systemd unit?
No. The systemd.exec manual says environment variables are not suitable for passing secrets: a unit's environment is exposed to unprivileged clients over D-Bus, so any local user can read it with systemctl show, and it is passed down to child processes. Use LoadCredential= and read the file from $CREDENTIALS_DIRECTORY, or an EnvironmentFile= that only root can read.
What does DynamicUser=yes do for security?
systemd allocates a throwaway user for the service while it runs, and, per systemd.exec(5), turns on NoNewPrivileges= and RestrictSUIDSGID=, implies ProtectSystem=strict and ProtectHome=read-only, and gives it a private /tmp. Use StateDirectory= for data it must keep.
Is this the same as systemd-analyze security?
No. systemd-analyze security scores a unit loaded on a running machine with its own weights. This tool reads the files themselves, so it works on units in a repository, a configuration-management template or a container image before they are deployed, and points at the line to change. It does not reproduce systemd-analyze's score.
Does a clean result mean my service is safe?
No. It reads only the settings listed here, does not see EnvironmentFile= contents, vendor drop-ins in other directories or the program itself, and cannot tell which privileges the service truly needs. Have a qualified person review anything that protects valuable data.
More: every setting this tool checks, what it blocks, and what it can break.