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/05/31"
  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"
 20risk_score = 47
 21rule_id = "84755a05-78c8-4430-8681-89cd6c857d71"
 22setup = """## Setup
 23
 24This rule requires data coming in from Elastic Defend.
 25
 26### Elastic Defend Integration Setup
 27Elastic 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.
 28
 29#### Prerequisite Requirements:
 30- Fleet is required for Elastic Defend.
 31- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 32
 33#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 34- Go to the Kibana home page and click "Add integrations".
 35- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 36- Click "Add Elastic Defend".
 37- Configure the integration name and optionally add a description.
 38- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 39- 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).
 40- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 41- 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.
 42For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 43- Click "Save and Continue".
 44- 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.
 45For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 46"""
 47severity = "medium"
 48tags = [
 49    "Domain: Endpoint",
 50    "OS: Linux",
 51    "Use Case: Threat Detection",
 52    "Tactic: Persistence",
 53    "Tactic: Privilege Escalation",
 54    "Tactic: Execution",
 55    "Data Source: Elastic Defend",
 56]
 57timestamp_override = "event.ingested"
 58type = "eql"
 59query = '''
 60file where host.os.type == "linux" and
 61event.action in ("rename", "creation") and file.path : "/var/spool/cron/atjobs/*" and not (
 62  process.executable in (
 63    "/bin/dpkg", "/usr/bin/dpkg", "/bin/dockerd", "/usr/bin/dockerd", "/usr/sbin/dockerd", "/bin/microdnf",
 64    "/usr/bin/microdnf", "/bin/rpm", "/usr/bin/rpm", "/bin/snapd", "/usr/bin/snapd", "/bin/yum", "/usr/bin/yum",
 65    "/bin/dnf", "/usr/bin/dnf", "/bin/podman", "/usr/bin/podman", "/bin/dnf-automatic", "/usr/bin/dnf-automatic",
 66    "/bin/pacman", "/usr/bin/pacman", "/usr/bin/dpkg-divert", "/bin/dpkg-divert", "/sbin/apk", "/usr/sbin/apk",
 67    "/usr/local/sbin/apk", "/usr/bin/apt", "/usr/sbin/pacman", "/bin/podman", "/usr/bin/podman", "/usr/bin/puppet",
 68    "/bin/puppet", "/opt/puppetlabs/puppet/bin/puppet", "/usr/bin/chef-client", "/bin/chef-client",
 69    "/bin/autossl_check", "/usr/bin/autossl_check", "/proc/self/exe", "/dev/fd/*",  "/usr/bin/pamac-daemon",
 70    "/bin/pamac-daemon", "/usr/local/bin/dockerd"
 71  ) or
 72  file.extension in ("swp", "swpx", "swx", "dpkg-remove") or
 73  file.Ext.original.extension == "dpkg-new" or
 74  process.executable : ("/nix/store/*", "/var/lib/dpkg/*", "/tmp/vmis.*", "/snap/*", "/dev/fd/*") or
 75  process.executable == null or
 76  (process.name == "sed" and file.name : "sed*") or
 77  (process.name == "perl" and file.name : "e2scrub_all.tmp*") 
 78)
 79'''
 80
 81[[rule.threat]]
 82framework = "MITRE ATT&CK"
 83
 84[[rule.threat.technique]]
 85id = "T1053"
 86name = "Scheduled Task/Job"
 87reference = "https://attack.mitre.org/techniques/T1053/"
 88
 89[[rule.threat.technique.subtechnique]]
 90id = "T1053.002"
 91name = "At"
 92reference = "https://attack.mitre.org/techniques/T1053/002/"
 93
 94[rule.threat.tactic]
 95id = "TA0003"
 96name = "Persistence"
 97reference = "https://attack.mitre.org/tactics/TA0003/"
 98
 99[[rule.threat]]
100framework = "MITRE ATT&CK"
101
102[[rule.threat.technique]]
103id = "T1053"
104name = "Scheduled Task/Job"
105reference = "https://attack.mitre.org/techniques/T1053/"
106
107[[rule.threat.technique.subtechnique]]
108id = "T1053.002"
109name = "At"
110reference = "https://attack.mitre.org/techniques/T1053/002/"
111
112[rule.threat.tactic]
113id = "TA0004"
114name = "Privilege Escalation"
115reference = "https://attack.mitre.org/tactics/TA0004/"
116
117[[rule.threat]]
118framework = "MITRE ATT&CK"
119
120[[rule.threat.technique]]
121id = "T1053"
122name = "Scheduled Task/Job"
123reference = "https://attack.mitre.org/techniques/T1053/"
124
125[[rule.threat.technique.subtechnique]]
126id = "T1053.002"
127name = "At"
128reference = "https://attack.mitre.org/techniques/T1053/002/"
129
130[rule.threat.tactic]
131id = "TA0002"
132name = "Execution"
133reference = "https://attack.mitre.org/tactics/TA0002/"

Related rules

to-top