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/09/23"
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 = [
22 "https://pwnshift.github.io/2020/10/01/persistence.html",
23 "https://www.elastic.co/security-labs/sequel-on-persistence-mechanisms",
24]
25risk_score = 21
26rule_id = "3fe4e20c-a600-4a86-9d98-3ecb1ef23550"
27setup = """## Setup
28This rule requires data coming in from Elastic Defend.
29
30### Elastic Defend Integration Setup
31Elastic 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.
32
33#### Prerequisite Requirements:
34- Fleet is required for Elastic Defend.
35- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
36
37#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
38- Go to the Kibana home page and click "Add integrations".
39- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
40- Click "Add Elastic Defend".
41- Configure the integration name and optionally add a description.
42- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
43- 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).
44- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
45- 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.
46
47For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
48- Click "Save and Continue".
49- 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.
50
51For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
52"""
53severity = "low"
54tags = [
55 "Domain: Endpoint",
56 "OS: Linux",
57 "Use Case: Threat Detection",
58 "Tactic: Persistence",
59 "Tactic: Defense Evasion",
60 "Data Source: Elastic Defend",
61]
62timestamp_override = "event.ingested"
63type = "eql"
64
65query = '''
66file where host.os.type == "linux" and event.action in ("rename", "creation") and
67file.path : ("/usr/lib/python*/site-packages/dnf-plugins/*", "/etc/dnf/plugins/*") and not (
68 process.executable in (
69 "/bin/dockerd", "/usr/bin/dockerd", "/usr/sbin/dockerd", "/bin/microdnf", "/usr/bin/microdnf", "/bin/rpm",
70 "/usr/bin/rpm", "/bin/snapd", "/usr/bin/snapd", "/bin/yum", "/usr/bin/yum", "/bin/dnf", "/usr/bin/dnf",
71 "/bin/podman", "/usr/bin/podman", "/bin/dnf-automatic", "/usr/bin/dnf-automatic", "/sbin/apk", "/usr/sbin/apk",
72 "/usr/local/sbin/apk", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet", "/bin/puppet",
73 "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client", "/bin/autossl_check",
74 "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd",
75 "/usr/libexec/netplan/generate"
76 ) or
77 file.extension in ("swp", "swpx", "swx") or
78 process.executable : (
79 "/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*", "/usr/lib/*", "/usr/libexec/*",
80 "/etc/kernel/*"
81 ) or
82 process.executable == null or
83 (process.name == "sed" and file.name : "sed*") or
84 (process.name == "perl" and file.name : "e2scrub_all.tmp*")
85)
86'''
87
88
89[[rule.threat]]
90framework = "MITRE ATT&CK"
91[[rule.threat.technique]]
92id = "T1543"
93name = "Create or Modify System Process"
94reference = "https://attack.mitre.org/techniques/T1543/"
95
96[[rule.threat.technique]]
97id = "T1546"
98name = "Event Triggered Execution"
99reference = "https://attack.mitre.org/techniques/T1546/"
100[[rule.threat.technique.subtechnique]]
101id = "T1546.016"
102name = "Installer Packages"
103reference = "https://attack.mitre.org/techniques/T1546/016/"
104
105
106[[rule.threat.technique]]
107id = "T1574"
108name = "Hijack Execution Flow"
109reference = "https://attack.mitre.org/techniques/T1574/"
110
111
112[rule.threat.tactic]
113id = "TA0003"
114name = "Persistence"
115reference = "https://attack.mitre.org/tactics/TA0003/"
116[[rule.threat]]
117framework = "MITRE ATT&CK"
118
119[rule.threat.tactic]
120id = "TA0005"
121name = "Defense Evasion"
122reference = "https://attack.mitre.org/tactics/TA0005/"
References
Related rules
- Git Hook Child Process
- Git Hook Command Execution
- Git Hook Egress Network Connection
- Suspicious APT Package Manager Execution
- Suspicious APT Package Manager Network Connection