DNF Package Manager Plugin File Creation

Detects file creation events in the plugin directories for the Yum package manager. In Linux, DNF (Dandified YUM) is a command-line utility used for handling packages on Fedora-based systems, providing functions for installing, updating, upgrading, and removing software along with managing package repositories. Attackers can backdoor DNF to gain persistence by injecting malicious code into plugins that DNF runs, thereby ensuring continued unauthorized access or control each time DNF is used for package management.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/06/25"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/07/09"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects file creation events in the plugin directories for the Yum package manager. In Linux, DNF (Dandified YUM) is a
 11command-line utility used for handling packages on Fedora-based systems, providing functions for installing, updating,
 12upgrading, and removing software along with managing package repositories. Attackers can backdoor DNF to gain
 13persistence by injecting malicious code into plugins that DNF runs, thereby ensuring continued unauthorized access or
 14control each time DNF is used for package management.
 15"""
 16from = "now-9m"
 17index = ["logs-endpoint.events.file*"]
 18language = "eql"
 19license = "Elastic License v2"
 20name = "DNF Package Manager Plugin File Creation"
 21references = ["https://pwnshift.github.io/2020/10/01/persistence.html"]
 22risk_score = 21
 23rule_id = "3fe4e20c-a600-4a86-9d98-3ecb1ef23550"
 24setup = """## Setup
 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 the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 29
 30#### Prerequisite Requirements:
 31- Fleet is required for Elastic Defend.
 32- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 33
 34#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 35- Go to the Kibana home page and click "Add integrations".
 36- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 37- Click "Add Elastic Defend".
 38- Configure the integration name and optionally add a description.
 39- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 40- 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).
 41- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 42- 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.
 43
 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.
 47
 48For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 49"""
 50severity = "low"
 51tags = [
 52    "Domain: Endpoint",
 53    "OS: Linux",
 54    "Use Case: Threat Detection",
 55    "Tactic: Persistence",
 56    "Tactic: Defense Evasion",
 57    "Data Source: Elastic Defend",
 58]
 59timestamp_override = "event.ingested"
 60type = "eql"
 61query = '''
 62file where host.os.type == "linux" and event.action in ("rename", "creation") and
 63file.path : ("/usr/lib/python*/site-packages/dnf-plugins/*", "/etc/dnf/plugins/*") and not (
 64  process.executable in (
 65    "/bin/dockerd", "/usr/bin/dockerd", "/usr/sbin/dockerd", "/bin/microdnf", "/usr/bin/microdnf", "/bin/rpm",
 66    "/usr/bin/rpm", "/bin/snapd", "/usr/bin/snapd", "/bin/yum", "/usr/bin/yum", "/bin/dnf", "/usr/bin/dnf",
 67    "/bin/podman", "/usr/bin/podman", "/bin/dnf-automatic", "/usr/bin/dnf-automatic", "/sbin/apk", "/usr/sbin/apk",
 68    "/usr/local/sbin/apk", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet", "/bin/puppet",
 69    "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client", "/bin/autossl_check",
 70    "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd",
 71    "/usr/libexec/netplan/generate"
 72  ) or
 73  file.extension in ("swp", "swpx", "swx") or
 74  process.executable : (
 75    "/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*", "/usr/lib/*", "/usr/libexec/*",
 76    "/etc/kernel/*"
 77  ) or
 78  process.executable == null or
 79  (process.name == "sed" and file.name : "sed*") or
 80  (process.name == "perl" and file.name : "e2scrub_all.tmp*") 
 81)
 82'''
 83
 84[[rule.threat]]
 85framework = "MITRE ATT&CK"
 86
 87[[rule.threat.technique]]
 88id = "T1546"
 89name = "Event Triggered Execution"
 90reference = "https://attack.mitre.org/techniques/T1546/"
 91
 92[[rule.threat.technique.subtechnique]]
 93id = "T1546.016"
 94name = "Installer Packages"
 95reference = "https://attack.mitre.org/techniques/T1546/016/"
 96
 97[[rule.threat.technique]]
 98id = "T1543"
 99name = "Create or Modify System Process"
100reference = "https://attack.mitre.org/techniques/T1543/"
101
102[[rule.threat.technique]]
103id = "T1574"
104name = "Hijack Execution Flow"
105reference = "https://attack.mitre.org/techniques/T1574/"
106
107[rule.threat.tactic]
108id = "TA0003"
109name = "Persistence"
110reference = "https://attack.mitre.org/tactics/TA0003/"
111
112[[rule.threat]]
113framework = "MITRE ATT&CK"
114
115[rule.threat.tactic]
116id = "TA0005"
117name = "Defense Evasion"
118reference = "https://attack.mitre.org/tactics/TA0005/"

References

Related rules

to-top