← All Threat Hunting ReportsThreat Hunting Exercise

Threat Hunting Exercise: Analyzing Linux Systemd Service Unit Persistence Dataset

This hunt uses a simulated Linux auditd/systemd dataset (linux_systemd_persist_2022-11-30T063000.json) capturing T1543.002: Create or Modify System Process: Systemd Service, where an attacker installs a malicious systemd unit file disguised with a legitimate-sounding name to achieve reboot-persistent execution with root privileges.

Step 1: Hypothesis Formation

Hypothesis: A new .service unit file is written to a systemd unit directory (/etc/systemd/system/, /usr/lib/systemd/system/) by a non-package-manager process, immediately followed by systemctl daemon-reload and systemctl enable --now on that unit, indicating deliberate persistence installation rather than legitimate software deployment. Indicators:

Null Hypothesis: A legitimate application or configuration-management tool (Ansible, Puppet, Chef) is deploying an approved systemd service as part of a scheduled configuration run. Invalidate by checking the writing process against the approved configuration-management agent and cross-referencing the deployment against a change ticket.

Rationale: Systemd service persistence is attractive because it survives reboots, runs as root by default unless explicitly restricted, and a well-named unit blends into the dozens of legitimate services already present on any Linux host, so detection depends on unit-file provenance (who wrote it, from where) rather than the unit name alone.

Step 2: Data Sources and Scope

Step 3: Key Findings

Parsed events (5 shown) confirm a malicious systemd unit disguised as a network-resolution service was written, enabled, and started on SVR-WEB-22 by a web-shell-spawned process, with its ExecStart pointing to a hidden binary in /var/tmp.

Timestamp (UTC)HostEventDetailIOC/Why Suspicious?
2022-11-30 06:30:02SVR-WEB-22auditd (PATH, CREATE)File created: /etc/systemd/system/systemd-networkd-resolved.service, owner www-dataTyposquat IOC: this filename closely mimics the legitimate systemd-resolved.service, but was written by the web-server user rather than the package manager during a system update.
2022-11-30 06:30:02SVR-WEB-22(File content)ExecStart=/var/tmp/.cache/.sysupd -d, Restart=always, User=rootExecStart-Anomaly IOC: the unit runs a hidden, dot-prefixed binary from /var/tmp as root with Restart=always - a persistence-and-resilience pattern with no legitimate system-service precedent.
2022-11-30 06:30:05SVR-WEB-22auditd (execve)systemctl daemon-reload executed by www-data (parent: sh spawned from apache2)Enable-Chain IOC: a web-server worker process invoking systemctl directly is never expected in normal application behavior and indicates a web shell is issuing OS-level persistence commands.
2022-11-30 06:30:07SVR-WEB-22auditd (execve)systemctl enable --now systemd-networkd-resolved.serviceActivation IOC: immediate enable-and-start confirms deliberate persistence installation, not a staged or reviewed deployment.
--(Config-mgmt correlation)No Ansible/Puppet run is logged for SVR-WEB-22 in this windowConfirms this was not a legitimate configuration-management-driven deployment.

Validation:

Step 4: Recommendations & Next Steps

Hypothesis confirmed - a compromised web application spawned a shell that wrote a typosquatted systemd service unit running a hidden root-level backdoor binary from /var/tmp, then enabled it for reboot-persistent execution!