Interview Prep/Linux/Processes, services and systemd

A security review says your services run with too many privileges. Which systemd hardening options would you add?

AdvancedScenarioProcesses, services and systemd
Answer

Situation read → Sandbox the service using systemd's built-in options.

What I'd do →

[Service]
User=app
NoNewPrivileges=yes
ProtectSystem=strict
ReadWritePaths=/var/lib/app /var/log/app
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
SystemCallFilter=@system-service
CapabilityBoundingSet=

Score it with systemd-analyze security app.service and iterate until the app still works.

Why → If the app is exploited, the attacker lands in a read-only, capability-free box.

Interview tip → Mention systemd-analyze security by name; it shows you've done this for real.

All Linux questions Roadmap: Linux

More on Processes, services and systemd