At Job Created or Modified
This rule monitors for at jobs being created or renamed. Linux at jobs are scheduled tasks that can be leveraged by system administrators to set up scheduled tasks, but may be abused by malicious actors for persistence, privilege escalation and command execution. By creating or modifying cron job configurations, attackers can execute malicious commands or scripts at predefined intervals, ensuring their continued presence and enabling unauthorized activities.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/05/31"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2024/09/23"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule monitors for at jobs being created or renamed. Linux at jobs are scheduled tasks that can be leveraged by
11system administrators to set up scheduled tasks, but may be abused by malicious actors for persistence, privilege
12escalation and command execution. By creating or modifying cron job configurations, attackers can execute malicious
13commands or scripts at predefined intervals, ensuring their continued presence and enabling unauthorized activities.
14"""
15from = "now-9m"
16index = ["logs-endpoint.events.file*"]
17language = "eql"
18license = "Elastic License v2"
19name = "At Job Created or Modified"
20references = ["https://www.elastic.co/security-labs/primer-on-persistence-mechanisms"]
21risk_score = 47
22rule_id = "84755a05-78c8-4430-8681-89cd6c857d71"
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 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.
43For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
44- Click "Save and Continue".
45- 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.
46For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
47"""
48severity = "medium"
49tags = [
50 "Domain: Endpoint",
51 "OS: Linux",
52 "Use Case: Threat Detection",
53 "Tactic: Persistence",
54 "Tactic: Privilege Escalation",
55 "Tactic: Execution",
56 "Data Source: Elastic Defend",
57]
58timestamp_override = "event.ingested"
59type = "eql"
60
61query = '''
62file where host.os.type == "linux" and
63event.action in ("rename", "creation") and file.path : "/var/spool/cron/atjobs/*" and not (
64 process.executable in (
65 "/bin/dpkg", "/usr/bin/dpkg", "/bin/dockerd", "/usr/bin/dockerd", "/usr/sbin/dockerd", "/bin/microdnf",
66 "/usr/bin/microdnf", "/bin/rpm", "/usr/bin/rpm", "/bin/snapd", "/usr/bin/snapd", "/bin/yum", "/usr/bin/yum",
67 "/bin/dnf", "/usr/bin/dnf", "/bin/podman", "/usr/bin/podman", "/bin/dnf-automatic", "/usr/bin/dnf-automatic",
68 "/bin/pacman", "/usr/bin/pacman", "/usr/bin/dpkg-divert", "/bin/dpkg-divert", "/sbin/apk", "/usr/sbin/apk",
69 "/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
70 "/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
71 "/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*", "/usr/bin/pamac-daemon",
72 "/bin/pamac-daemon", "/usr/local/bin/dockerd"
73 ) or
74 file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
75 file.Ext.original.extension == "dpkg-new" or
76 process.executable : ("/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*") or
77 process.executable == null or
78 (process.name == "sed" and file.name : "sed*") or
79 (process.name == "perl" and file.name : "e2scrub_all.tmp*")
80)
81'''
82
83
84[[rule.threat]]
85framework = "MITRE ATT&CK"
86[[rule.threat.technique]]
87id = "T1053"
88name = "Scheduled Task/Job"
89reference = "https://attack.mitre.org/techniques/T1053/"
90[[rule.threat.technique.subtechnique]]
91id = "T1053.002"
92name = "At"
93reference = "https://attack.mitre.org/techniques/T1053/002/"
94
95
96
97[rule.threat.tactic]
98id = "TA0003"
99name = "Persistence"
100reference = "https://attack.mitre.org/tactics/TA0003/"
101[[rule.threat]]
102framework = "MITRE ATT&CK"
103[[rule.threat.technique]]
104id = "T1053"
105name = "Scheduled Task/Job"
106reference = "https://attack.mitre.org/techniques/T1053/"
107[[rule.threat.technique.subtechnique]]
108id = "T1053.002"
109name = "At"
110reference = "https://attack.mitre.org/techniques/T1053/002/"
111
112
113
114[rule.threat.tactic]
115id = "TA0004"
116name = "Privilege Escalation"
117reference = "https://attack.mitre.org/tactics/TA0004/"
118[[rule.threat]]
119framework = "MITRE ATT&CK"
120[[rule.threat.technique]]
121id = "T1053"
122name = "Scheduled Task/Job"
123reference = "https://attack.mitre.org/techniques/T1053/"
124[[rule.threat.technique.subtechnique]]
125id = "T1053.002"
126name = "At"
127reference = "https://attack.mitre.org/techniques/T1053/002/"
128
129
130
131[rule.threat.tactic]
132id = "TA0002"
133name = "Execution"
134reference = "https://attack.mitre.org/tactics/TA0002/"
References
Related rules
- Git Hook Child Process
- Git Hook Command Execution
- Git Hook Egress Network Connection
- Potential Sudo Hijacking
- Suspicious APT Package Manager Execution