The score is calculated from the unit settings loaded into systemd, not from what the live process is running with. If you add a sandbox and run daemon-reload without restarting the service, the score already reads 1.7 OK while the process still holds all 41 root capabilities:
sudo systemctl daemon-reload
systemd-analyze security crowdsec-firewall-bouncer --no-pager | tail -1
# → Overall exposure level for crowdsec-firewall-bouncer.service: 1.7 OK :-)
grep CapBnd /proc/$(pidof crowdsec-firewall-bouncer)/status
# CapBnd: 000001ffffffffff
sudo systemctl restart crowdsec-firewall-bouncer
grep CapBnd /proc/$(pidof crowdsec-firewall-bouncer)/status
# CapBnd: 0000000000001000
After changing a sandbox, verify both the score and the live process: check capabilities in /proc/<pid>/status and filesystem view with nsenter, as shown in “How to check” in systemd sandbox.
On a fresh Ubuntu install, almost everything is UNSAFE
Without a service name, the command scores every loaded service at once, no sudo needed:
$ systemd-analyze security --no-pager
UNIT EXPOSURE PREDICATE HAPPY
cron.service 9.6 UNSAFE :-{
docker.service 9.6 UNSAFE :-{
ssh.service 9.6 UNSAFE :-{
systemd-journald.service 4.3 OK :-)
systemd-resolved.service 2.2 OK :-)
systemd-timesyncd.service 2.1 OK :-)
unattended-upgrades.service 9.6 UNSAFE :-{
…
OK belongs to systemd’s own daemons because their packaged units already include sandbox directives. Other services omit them, and that does not mean the server is exposed. sshd spawns shells for any logged-in user and switches UIDs; Docker creates networks and mounts container volumes — both need nearly full root privileges, so heavy sandboxing does not fit them. Sandbox services with narrow jobs: the CrowdSec bouncer only polls LAPI over HTTP and updates nftables, which drops its score from 9.6 to 1.7 (systemd sandbox). Lines marked ✗ in systemd-analyze security <service> show what else can be locked down.
Script thresholds are in tenths
--threshold returns a non-zero exit code when a service scores above the limit, using a 0–100 scale. A service at 1.7 passes --threshold=17 and fails --threshold=16:
systemd-analyze security --threshold=20 crowdsec-firewall-bouncer --no-pager > /dev/null; echo $?
# 0
systemd-analyze security --threshold=20 crowdsec-firewall-bouncer ssh --no-pager > /dev/null; echo $?
# 1 — ssh scores 9.6
With --offline=yes, the command evaluates a standalone unit file, such as a copy from git. It still pulls in .service.d/ drop-ins from the host by matching filename: a copy named crowdsec-firewall-bouncer.service in /tmp inherits the host sandbox and scores 1.7 OK, while the exact same file under a different name scores 9.4 UNSAFE.
If it doesn’t work
Added a sandbox and the score changed to OK, but /proc/<pid>/status still shows CapBnd: 000001ffffffffff
- Cause
- You ran
daemon-reloadwithoutrestart. The score reads the loaded unit configuration, while the running process still has its old settings. - Fix
- Run
sudo systemctl restart <service>so the new process starts inside the sandbox.
Added a sandbox drop-in, and the score stayed the same
- Cause
- systemd has not reloaded the files: the score comes from the loaded unit, not directly from disk.
- Fix
- Run
sudo systemctl daemon-reload, thenrestart.
--threshold=5 exits with an error even for a service scored 1.7
- Cause
- The threshold uses a 0–100 scale, so
5means 0.5. - Fix
- Multiply the target score by 10: “at most 2.0” is
--threshold=20.
--offline=yes reports sandbox settings that are not in the file being checked
- Cause
- The file matches an installed unit name, and systemd merged drop-ins from the host’s
/etc/systemd/system/<name>.service.d/. - Fix
- Test a copy under a different filename, or pass a combined file containing both the unit and its sandbox directives.
On a fresh server, almost every service is marked UNSAFE, including ssh and docker
- Cause
- The score counts disabled protections, and most packaged services ship without sandboxing.
- Fix
- Nothing is wrong with the server. Add sandboxes to services with narrow needs (systemd sandbox).