Adversaries may create or modify systemd services to repeatedly execute malicious payloads as part of persistence. Systemd is a system and service manager commonly used for managing background daemon processes (also known as services) and other system resources.[1] Systemd is the default initialization (init) system on many Linux distributions replacing legacy init systems, including SysVinit and Upstart, while remaining backwards compatible.

Systemd utilizes unit configuration files with the .service file extension to encode information about a service's process. By default, system level unit files are stored in the /systemd/system directory of the root owned directories (/). User level unit files are stored in the /systemd/user directories of the user owned directories ($HOME).[2]

Inside the .service unit files, the following directives are used to execute commands:[3]

Adversaries have created new service files, altered the commands a .service file’s directive executes, and modified the user directive a .service file executes as, which could result in privilege escalation. Adversaries may also place symbolic links in these directories, enabling systemd to find these payloads regardless of where they reside on the filesystem.[4],[5],[6]

The .service file’s User directive can be used to run service as a specific user, which could result in privilege escalation based on specific user/group permissions.

Systemd services can be created via systemd generators, which support the dynamic generation of unit files. Systemd generators are small executables that run during boot or configuration reloads to dynamically create or modify systemd unit files by converting non-native configurations into services, symlinks, or drop-ins (i.e., Boot or Logon Initialization Scripts).[7],[8]

References

  1. Linux man-pages. (2014, January). systemd(1) - Linux manual page. Retrieved April 23, 2019.
  2. Tony Lambert. (2022, November 13). ATT&CK T1501: Understanding systemd service persistence. Retrieved March 20, 2023.
  3. Free Desktop. (n.d.). systemd.service — Service unit configuration. Retrieved March 20, 2023.
  4. Anomali Labs. (2019, March 15). Rocke Evolves Its Arsenal With a New Malware Family Written in Golang. Retrieved April 24, 2019.
  5. airwalk. (2023, January 1). A guide to backdooring Unix systems. Retrieved May 31, 2023.
  6. Rapid7. (2016, June 22). Service Persistence. Retrieved April 23, 2019.
  7. Ruben Groenewoud. (2024, August 20). Linux Detection Engineering - A primer on persistence mechanisms. Retrieved March 18, 2025.
  8. Pepe Berba. (2022, February 7). Hunting for Persistence in Linux (Part 5): Systemd Generators. Retrieved April 8, 2025.

Ticket collegati

Collegamenti
Tipo di collegamento Ticket
is related to Techniques
is blocked by Detection of Systemd Service Creation or Modification on Linux
is blocked by User Account Management
is blocked by Restrict File and Directory Permissions
is blocked by Privileged Account Management
is blocked by Limit Software Installation
is blocked by Change Management Program
is blocked by Prohibition Of Changes
is blocked by Statutory, Regulatory & Contractual Compliance
is blocked by Configuration Management Program
is blocked by Configure Technology Assets, Applications and/or Services (TAAS) for High-Risk Areas
is blocked by Continuous Monitoring Policy
is blocked by Malicious Code Protection (Antimalware)
is blocked by Documented Endpoint Security Protection Measures
is blocked by Personnel Transfer
is blocked by Identity & Access Management (IAM)
is blocked by Password-Based Authentication
is blocked by Authenticator Feedback
is blocked by Restrictions on Shared Groups / Accounts
is blocked by Security Function Isolation
is blocked by Security, Compliance & Resilience Testing Throughout Development
is blocked by Unsupported Technology Assets, Applications and/or Services (TAAS)
is blocked by Configuration Change Control
is blocked by Access Restriction For Change
is blocked by Executive Leadership Oversight of Security, Compliance & Resilience Controls
is blocked by Secure Baseline Configurations
is blocked by Restrict Roles Permitted To Install Software
is blocked by Continuous Monitoring
is blocked by Endpoint File Integrity Monitoring (FIM)
is blocked by Separation of Duties (SoD)
is blocked by Account Management
is blocked by Access Enforcement
is blocked by Least Privilege
is blocked by Identification & Authentication for Organizational Users
is blocked by Memory Protection