Skip to main content

Overview

Systemd manages services on modern Linux. If you can modify a .service file, its binary, or exploit relative paths, you get code execution as the user running the service (often root).

Find Writable Service Files

Check Drop-in Directories

Drop-in files (/etc/systemd/system/<unit>.d/*.conf) override service settings.

Exploit Writable .service File

Modify ExecStart

Replace ExecStart:
Reload and restart:

Reverse Shell via Service


Exploit via Drop-in Override

If /etc/systemd/system/<unit>.d/ is writable:
Empty ExecStart= line is required before the new one — systemd appends otherwise.

Writable Service Binary

If the binary a service executes is writable:
If writable:
Wait for service restart or:

Systemd PATH Hijacking

systemd does not use the environment $PATH (from systemctl show-environment) to resolve a relative ExecStart binary. It uses a fixed compile-time search path — typically /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin. The hijack only works if one of those standard directories is writable.
If a service uses a relative binary name and one of those standard dirs is writable:

Writable Timer Files

Modify timer to point to malicious service:
Create malicious.service:

Writable Socket Files

Inject ExecStartPre to execute before socket activation:

Create Missing Service for Socket

If a .socket exists but the .service it activates is missing:
Create the service:

Enumerate All Services Running as Root

Check each service binary permissions: