APT Package Manager Configuration File Creation
Detects file creation events in the configuration directory for the APT package manager. In Linux, APT (Advanced Package Tool) is a command-line utility used for handling packages on (by default) Debian-based systems, providing functions for installing, updating, upgrading, and removing software along with managing package repositories. Attackers can backdoor APT to gain persistence by injecting malicious code into scripts that APT runs, thereby ensuring continued unauthorized access or control each time APT is used for package management.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/06/03"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2024/10/17"
6
7[rule]
8author = ["Elastic"]
9description = """
10Detects file creation events in the configuration directory for the APT package manager. In Linux, APT (Advanced Package
11Tool) is a command-line utility used for handling packages on (by default) Debian-based systems, providing functions for
12installing, updating, upgrading, and removing software along with managing package repositories. Attackers can backdoor
13APT to gain persistence by injecting malicious code into scripts that APT runs, thereby ensuring continued unauthorized
14access or control each time APT is used for package management.
15"""
16from = "now-9m"
17index = ["logs-endpoint.events.file*"]
18language = "eql"
19license = "Elastic License v2"
20name = "APT Package Manager Configuration File Creation"
21references = [
22 "https://packetstormsecurity.com/files/152668/APT-Package-Manager-Persistence.html",
23 "https://www.elastic.co/security-labs/sequel-on-persistence-mechanisms",
24]
25risk_score = 47
26rule_id = "7c2e1297-7664-42bc-af11-6d5d35220b6b"
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 = "medium"
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]
61timestamp_override = "event.ingested"
62type = "eql"
63
64query = '''
65file where host.os.type == "linux" and event.action in ("rename", "creation") and
66file.path : "/etc/apt/apt.conf.d/*" and not (
67 process.executable in (
68 "/bin/dpkg", "/usr/bin/dpkg", "/bin/dockerd", "/usr/bin/dockerd", "/usr/sbin/dockerd", "/bin/microdnf",
69 "/usr/bin/microdnf", "/bin/rpm", "/usr/bin/rpm", "/bin/snapd", "/usr/bin/snapd", "/bin/yum", "/usr/bin/yum",
70 "/bin/dnf", "/usr/bin/dnf", "/bin/podman", "/usr/bin/podman", "/bin/dnf-automatic", "/usr/bin/dnf-automatic",
71 "/bin/pacman", "/usr/bin/pacman", "/usr/bin/dpkg-divert", "/bin/dpkg-divert", "/sbin/apk", "/usr/sbin/apk",
72 "/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
73 "/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
74 "/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
75 "/bin/pamac-daemon", "/usr/lib/snapd/snapd", "/usr/local/bin/dockerd", "/usr/libexec/netplan/generate",
76 "/usr/local/bin/apt-get", "/usr/bin/apt-get"
77 ) or
78 file.path :("/etc/apt/apt.conf.d/*.tmp*") or
79 file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
80 file.Ext.original.extension == "dpkg-new" or
81 process.executable : (
82 "/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*", "/usr/lib/*", "/usr/libexec/*",
83 "/etc/kernel/*"
84 ) or
85 process.executable == null or
86 process.name in ("pveupdate", "perl") or
87 (process.name == "sed" and file.name : "sed*") or
88 (process.name == "perl" and file.name : "e2scrub_all.tmp*")
89)
90'''
91
92
93[[rule.threat]]
94framework = "MITRE ATT&CK"
95[[rule.threat.technique]]
96id = "T1543"
97name = "Create or Modify System Process"
98reference = "https://attack.mitre.org/techniques/T1543/"
99
100[[rule.threat.technique]]
101id = "T1546"
102name = "Event Triggered Execution"
103reference = "https://attack.mitre.org/techniques/T1546/"
104[[rule.threat.technique.subtechnique]]
105id = "T1546.016"
106name = "Installer Packages"
107reference = "https://attack.mitre.org/techniques/T1546/016/"
108
109
110[[rule.threat.technique]]
111id = "T1574"
112name = "Hijack Execution Flow"
113reference = "https://attack.mitre.org/techniques/T1574/"
114
115
116[rule.threat.tactic]
117id = "TA0003"
118name = "Persistence"
119reference = "https://attack.mitre.org/tactics/TA0003/"
120[[rule.threat]]
121framework = "MITRE ATT&CK"
122
123[rule.threat.tactic]
124id = "TA0005"
125name = "Defense Evasion"
126reference = "https://attack.mitre.org/tactics/TA0005/"
References
Related rules
- Git Hook Created or Modified
- Suspicious Network Connection via systemd
- Yum Package Manager Plugin File Creation
- Kernel Load or Unload via Kexec Detected
- Dynamic Linker Creation or Modification