Systemd-udevd Rule File Creation

Monitors for the creation of rule files that are used by systemd-udevd to manage device nodes and handle kernel device events in the Linux operating system. Systemd-udevd can be exploited for persistence by adversaries by creating malicious udev rules that trigger on specific events, executing arbitrary commands or payloads whenever a certain device is plugged in or recognized by the system.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/10/26"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/10/17"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Monitors for the creation of rule files that are used by systemd-udevd to manage device nodes and handle kernel device
 11events in the Linux operating system. Systemd-udevd can be exploited for persistence by adversaries by creating
 12malicious udev rules that trigger on specific events, executing arbitrary commands or payloads whenever a certain device
 13is plugged in or recognized by the system.
 14"""
 15from = "now-9m"
 16index = ["logs-endpoint.events.file*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Systemd-udevd Rule File Creation"
 20references = ["https://www.elastic.co/security-labs/sequel-on-persistence-mechanisms"]
 21risk_score = 21
 22rule_id = "054db96b-fd34-43b3-9af2-587b3bd33964"
 23setup = """## Setup
 24
 25This rule requires data coming in from Elastic Defend.
 26
 27### Elastic Defend Integration Setup
 28Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows
 29the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 30
 31#### Prerequisite Requirements:
 32- Fleet is required for Elastic Defend.
 33- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 34
 35#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 36- Go to the Kibana home page and click Add integrations.
 37- In the query bar, search for Elastic Defend and select the integration to see more details about it.
 38- Click Add Elastic Defend.
 39- Configure the integration name and optionally add a description.
 40- Select the type of environment you want to protect, either Traditional Endpoints or Cloud Workloads.
 41- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
 42- We suggest to select "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 43- Enter a name for the agent policy in New agent policy name. If other agent policies already exist, you can click the Existing hosts tab and select an existing policy instead.
 44For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 45- Click Save and Continue.
 46- To complete the integration, select Add Elastic Agent to your hosts and continue to the next section to install the Elastic Agent on your hosts.
 47For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 48"""
 49severity = "low"
 50tags = [
 51    "Domain: Endpoint",
 52    "OS: Linux",
 53    "Use Case: Threat Detection",
 54    "Tactic: Persistence",
 55    "Data Source: Elastic Defend",
 56]
 57timestamp_override = "event.ingested"
 58type = "eql"
 59query = '''
 60file where host.os.type == "linux" and event.action in ("rename", "creation") and 
 61process.executable != null and file.extension == "rules" and
 62file.path : (
 63  "/lib/udev/*", "/etc/udev/rules.d/*", "/usr/lib/udev/rules.d/*", "/run/udev/rules.d/*", "/usr/local/lib/udev/rules.d/*"
 64) and not (
 65  process.executable in (
 66    "/bin/dpkg", "/usr/bin/dpkg", "/bin/dockerd", "/usr/bin/dockerd", "/usr/sbin/dockerd", "/bin/microdnf",
 67    "/usr/bin/microdnf", "/bin/rpm", "/usr/bin/rpm", "/bin/snapd", "/usr/bin/snapd", "/bin/yum", "/usr/bin/yum",
 68    "/bin/dnf", "/usr/bin/dnf", "/bin/podman", "/usr/bin/podman", "/bin/dnf-automatic", "/usr/bin/dnf-automatic",
 69    "/bin/pacman", "/usr/bin/pacman", "/usr/bin/dpkg-divert", "/bin/dpkg-divert", "/sbin/apk", "/usr/sbin/apk",
 70    "/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
 71    "/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
 72    "/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*",  "/usr/bin/pamac-daemon",
 73    "/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/libexec/netplan/generate",
 74    "/lib/systemd/system-generators/netplan", "/lib/systemd/systemd", "/usr/bin/containerd", "/usr/sbin/sshd",
 75    "/kaniko/executor"
 76  ) or
 77  file.Ext.original.extension == "dpkg-new" or
 78  process.executable : (
 79    "/nix/store/*", "/var/lib/dpkg/*", "/snap/*", "/dev/fd/*", "/usr/lib/*", "/usr/libexec/*"
 80  ) or
 81  process.name in ("systemd", "netplan", "apt-get", "vmware-config-tools.pl", "systemd-hwdb") or
 82  (process.name == "sed" and file.name : "sed*") or
 83  (process.name == "perl" and file.name : "e2scrub_all.tmp*") 
 84)
 85'''
 86
 87[[rule.threat]]
 88framework = "MITRE ATT&CK"
 89
 90[[rule.threat.technique]]
 91id = "T1037"
 92name = "Boot or Logon Initialization Scripts"
 93reference = "https://attack.mitre.org/techniques/T1037/"
 94
 95[[rule.threat.technique]]
 96id = "T1546"
 97name = "Event Triggered Execution"
 98reference = "https://attack.mitre.org/techniques/T1546/"
 99
100[rule.threat.tactic]
101id = "TA0003"
102name = "Persistence"
103reference = "https://attack.mitre.org/tactics/TA0003/"

References

Related rules

to-top