Yum Package Manager Plugin File Creation

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

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/06/25"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2025/01/24"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects file creation events in the plugin directories for the Yum package manager. In Linux, Yum (Yellowdog Updater,
 11Modified) is a command-line utility used for handling packages on (by default) Fedora-based systems, providing functions
 12for installing, updating, upgrading, and removing software along with managing package repositories. Attackers can
 13backdoor Yum to gain persistence by injecting malicious code into plugins that Yum runs, thereby ensuring continued
 14unauthorized access or control each time Yum is used for package management.
 15"""
 16from = "now-9m"
 17index = ["logs-endpoint.events.file*"]
 18language = "eql"
 19license = "Elastic License v2"
 20name = "Yum Package Manager Plugin File Creation"
 21references = [
 22    "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/local/yum_package_manager_persistence.rb",
 23    "https://www.elastic.co/security-labs/sequel-on-persistence-mechanisms",
 24]
 25risk_score = 21
 26rule_id = "0b15bcad-aff1-4250-a5be-5d1b7eb56d07"
 27setup = """## Setup
 28
 29This rule requires data coming in from Elastic Defend.
 30
 31### Elastic Defend Integration Setup
 32Elastic 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.
 33
 34#### Prerequisite Requirements:
 35- Fleet is required for Elastic Defend.
 36- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 37
 38#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 39- Go to the Kibana home page and click "Add integrations".
 40- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 41- Click "Add Elastic Defend".
 42- Configure the integration name and optionally add a description.
 43- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 44- 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).
 45- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 46- 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.
 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.
 50For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 51"""
 52severity = "low"
 53tags = [
 54    "Domain: Endpoint",
 55    "OS: Linux",
 56    "Use Case: Threat Detection",
 57    "Tactic: Persistence",
 58    "Tactic: Defense Evasion",
 59    "Data Source: Elastic Defend",
 60    "Resources: Investigation Guide",
 61]
 62timestamp_override = "event.ingested"
 63type = "eql"
 64query = '''
 65file where host.os.type == "linux" and event.action in ("rename", "creation") and
 66file.path : ("/usr/lib/yum-plugins/*", "/etc/yum/pluginconf.d/*") and not (
 67  process.executable in (
 68    "/bin/dockerd", "/usr/bin/dockerd", "/usr/sbin/dockerd", "/bin/microdnf", "/usr/bin/microdnf", "/bin/rpm",
 69    "/usr/bin/rpm", "/bin/snapd", "/usr/bin/snapd", "/bin/yum", "/usr/bin/yum", "/bin/dnf", "/usr/bin/dnf",
 70    "/bin/podman", "/usr/bin/podman", "/bin/dnf-automatic", "/usr/bin/dnf-automatic", "/sbin/apk", "/usr/sbin/apk",
 71    "/usr/local/sbin/apk", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet", "/bin/puppet",
 72    "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client", "/bin/autossl_check",
 73    "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd",
 74    "/usr/libexec/netplan/generate"
 75  ) or
 76  process.name in ("yumBackend.py", "crio") or
 77  file.extension in ("swp", "swpx", "swx") or
 78  file.Ext.original.name like ".ansible*" or
 79  file.name like ".ansible_tmp*" or
 80  process.executable : (
 81    "/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*", "/usr/lib/*", "/usr/libexec/*",
 82    "/etc/kernel/*"
 83  ) or
 84  process.executable == null or
 85  (process.name == "sed" and file.name : "sed*") or
 86  (process.name == "perl" and file.name : "e2scrub_all.tmp*")
 87)
 88'''
 89note = """## Triage and analysis
 90
 91> **Disclaimer**:
 92> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
 93
 94### Investigating Yum Package Manager Plugin File Creation
 95
 96The Yum package manager is integral to managing software on Fedora-based Linux systems, utilizing plugins to extend its functionality. Adversaries may exploit this by inserting malicious code into these plugins, ensuring persistent access whenever Yum is executed. The detection rule identifies suspicious file creation in plugin directories, excluding legitimate processes and temporary files, to flag potential unauthorized modifications.
 97
 98### Possible investigation steps
 99
100- Review the file creation event details, focusing on the file path to confirm if it matches the plugin directories "/usr/lib/yum-plugins/*" or "/etc/yum/pluginconf.d/*".
101- Identify the process responsible for the file creation by examining the process.executable field, ensuring it is not one of the legitimate processes listed in the exclusion criteria.
102- Check the file extension and name to ensure it is not a temporary or excluded file type, such as those with extensions "swp", "swpx", "swx", or names starting with ".ansible".
103- Investigate the origin and legitimacy of the process by correlating with other system logs or using threat intelligence to determine if the process is known to be associated with malicious activity.
104- Assess the file content for any signs of malicious code or unauthorized modifications, especially if the file is a script or configuration file.
105- Determine if there have been any recent changes or updates to the system that could explain the file creation, such as legitimate software installations or updates.
106
107### False positive analysis
108
109- Legitimate software updates or installations may trigger file creation events in Yum plugin directories. To handle these, users can create exceptions for known package management processes like rpm, dnf, and yum, which are already included in the rule's exclusion list.
110- Temporary files created by text editors or system processes, such as those with extensions like swp, swpx, or swx, can be safely excluded as they are typically non-threatening. Ensure these extensions are part of the exclusion criteria.
111- Automation tools like Ansible may generate temporary files in the plugin directories. Users can exclude file names starting with .ansible or .ansible_tmp to prevent false positives from these operations.
112- Processes running from specific directories like /nix/store or /var/lib/dpkg are often part of legitimate system operations. Users should verify these paths and include them in the exclusion list if they are part of regular system behavior.
113- System maintenance scripts or tools like sed and perl may create temporary files during their execution. Users can exclude these specific process names and file patterns to reduce false alerts.
114
115### Response and remediation
116
117- Isolate the affected system from the network to prevent further unauthorized access or lateral movement by the adversary.
118- Terminate any suspicious processes that may be running as a result of the malicious plugin modification to halt any ongoing malicious activity.
119- Restore the compromised plugin files from a known good backup to ensure the integrity of the Yum package manager's functionality.
120- Conduct a thorough review of user accounts and permissions on the affected system to identify and remove any unauthorized access or privilege escalations.
121- Implement file integrity monitoring on the Yum plugin directories to detect any future unauthorized modifications promptly.
122- Escalate the incident to the security operations team for further investigation and to determine if additional systems may be affected.
123- Update and patch the system to the latest security standards to mitigate any vulnerabilities that may have been exploited by the adversary."""
124
125[[rule.threat]]
126framework = "MITRE ATT&CK"
127
128[[rule.threat.technique]]
129id = "T1543"
130name = "Create or Modify System Process"
131reference = "https://attack.mitre.org/techniques/T1543/"
132
133[[rule.threat.technique]]
134id = "T1546"
135name = "Event Triggered Execution"
136reference = "https://attack.mitre.org/techniques/T1546/"
137
138[[rule.threat.technique.subtechnique]]
139id = "T1546.016"
140name = "Installer Packages"
141reference = "https://attack.mitre.org/techniques/T1546/016/"
142
143[[rule.threat.technique]]
144id = "T1574"
145name = "Hijack Execution Flow"
146reference = "https://attack.mitre.org/techniques/T1574/"
147
148[rule.threat.tactic]
149id = "TA0003"
150name = "Persistence"
151reference = "https://attack.mitre.org/tactics/TA0003/"
152
153[[rule.threat]]
154framework = "MITRE ATT&CK"
155
156[rule.threat.tactic]
157id = "TA0005"
158name = "Defense Evasion"
159reference = "https://attack.mitre.org/tactics/TA0005/"
...
toml

Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.

The Yum package manager is integral to managing software on Fedora-based Linux systems, utilizing plugins to extend its functionality. Adversaries may exploit this by inserting malicious code into these plugins, ensuring persistent access whenever Yum is executed. The detection rule identifies suspicious file creation in plugin directories, excluding legitimate processes and temporary files, to flag potential unauthorized modifications.

  • Review the file creation event details, focusing on the file path to confirm if it matches the plugin directories "/usr/lib/yum-plugins/" or "/etc/yum/pluginconf.d/".
  • Identify the process responsible for the file creation by examining the process.executable field, ensuring it is not one of the legitimate processes listed in the exclusion criteria.
  • Check the file extension and name to ensure it is not a temporary or excluded file type, such as those with extensions "swp", "swpx", "swx", or names starting with ".ansible".
  • Investigate the origin and legitimacy of the process by correlating with other system logs or using threat intelligence to determine if the process is known to be associated with malicious activity.
  • Assess the file content for any signs of malicious code or unauthorized modifications, especially if the file is a script or configuration file.
  • Determine if there have been any recent changes or updates to the system that could explain the file creation, such as legitimate software installations or updates.
  • Legitimate software updates or installations may trigger file creation events in Yum plugin directories. To handle these, users can create exceptions for known package management processes like rpm, dnf, and yum, which are already included in the rule's exclusion list.
  • Temporary files created by text editors or system processes, such as those with extensions like swp, swpx, or swx, can be safely excluded as they are typically non-threatening. Ensure these extensions are part of the exclusion criteria.
  • Automation tools like Ansible may generate temporary files in the plugin directories. Users can exclude file names starting with .ansible or .ansible_tmp to prevent false positives from these operations.
  • Processes running from specific directories like /nix/store or /var/lib/dpkg are often part of legitimate system operations. Users should verify these paths and include them in the exclusion list if they are part of regular system behavior.
  • System maintenance scripts or tools like sed and perl may create temporary files during their execution. Users can exclude these specific process names and file patterns to reduce false alerts.
  • Isolate the affected system from the network to prevent further unauthorized access or lateral movement by the adversary.
  • Terminate any suspicious processes that may be running as a result of the malicious plugin modification to halt any ongoing malicious activity.
  • Restore the compromised plugin files from a known good backup to ensure the integrity of the Yum package manager's functionality.
  • Conduct a thorough review of user accounts and permissions on the affected system to identify and remove any unauthorized access or privilege escalations.
  • Implement file integrity monitoring on the Yum plugin directories to detect any future unauthorized modifications promptly.
  • Escalate the incident to the security operations team for further investigation and to determine if additional systems may be affected.
  • Update and patch the system to the latest security standards to mitigate any vulnerabilities that may have been exploited by the adversary.

References

Related rules

to-top