Network Connections Initiated Through XDG Autostart Entry

Detects network connections initiated through Cross-Desktop Group (XDG) autostart entries for GNOME and XFCE-based Linux distributions. XDG Autostart entries can be used to execute arbitrary commands or scripts when a user logs in. This rule helps to identify potential malicious activity where an attacker may have modified XDG autostart scripts to establish persistence on the system.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/06/03"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/07/18"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects network connections initiated through Cross-Desktop Group (XDG) autostart entries for GNOME and XFCE-based
 11Linux distributions. XDG Autostart entries can be used to execute arbitrary commands or scripts when a user logs in.
 12This rule helps to identify potential malicious activity where an attacker may have modified XDG autostart scripts
 13to establish persistence on the system.
 14"""
 15from = "now-9m"
 16index = ["logs-endpoint.events.*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Network Connections Initiated Through XDG Autostart Entry"
 20references = [
 21  "https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html",
 22  "https://hadess.io/the-art-of-linux-persistence/"
 23]
 24risk_score = 47
 25rule_id = "dd52d45a-4602-4195-9018-ebe0f219c273"
 26setup = """## Setup
 27
 28This rule requires data coming in from one of the following integrations:
 29- Elastic Defend
 30- Auditbeat
 31
 32### Elastic Defend Integration Setup
 33Elastic 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.
 34
 35#### Prerequisite Requirements:
 36- Fleet is required for Elastic Defend.
 37- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 38
 39#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 40- Go to the Kibana home page and click "Add integrations".
 41- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 42- Click "Add Elastic Defend".
 43- Configure the integration name and optionally add a description.
 44- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 45- 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).
 46- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 47- 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.
 48For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 49- Click "Save and Continue".
 50- 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.
 51For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 52
 53### Auditbeat Setup
 54Auditbeat is a lightweight shipper that you can install on your servers to audit the activities of users and processes on your systems. For example, you can use Auditbeat to collect and centralize audit events from the Linux Audit Framework. You can also use Auditbeat to detect changes to critical files, like binaries and configuration files, and identify potential security policy violations.
 55
 56#### The following steps should be executed in order to add the Auditbeat on a Linux System:
 57- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
 58- To install the APT and YUM repositories follow the setup instructions in this [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setup-repositories.html).
 59- To run Auditbeat on Docker follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-docker.html).
 60- To run Auditbeat on Kubernetes follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-kubernetes.html).
 61- For complete “Setup and Run Auditbeat” information refer to the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setting-up-and-running.html).
 62
 63#### Custom Ingest Pipeline
 64For versions <8.2, you need to add a custom ingest pipeline to populate `event.ingested` with @timestamp for non-elastic-agent indexes, like auditbeats/filebeat/winlogbeat etc. For more details to add a custom ingest pipeline refer to the [guide](https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html).
 65"""
 66severity = "medium"
 67tags = [
 68    "Domain: Endpoint",
 69    "OS: Linux",
 70    "Use Case: Threat Detection",
 71    "Tactic: Persistence",
 72    "Data Source: Elastic Defend"
 73]
 74timestamp_override = "event.ingested"
 75type = "eql"
 76query = '''
 77sequence by host.id, process.entity_id with maxspan=1s
 78  [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and (
 79     (process.parent.executable == "/usr/bin/xfce4-session") or
 80     (process.executable == "/bin/sh" and process.args == "-e" and process.args == "-u" and
 81      process.args == "-c" and process.args : "export GIO_LAUNCHED_DESKTOP_FILE_PID=$$;*")
 82   )
 83  ]
 84  [network where host.os.type == "linux" and event.type == "start" and event.action == "connection_attempted" and not (
 85     destination.ip == null or destination.ip == "0.0.0.0" or cidrmatch(
 86       destination.ip, "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.0.0/29",
 87       "192.0.0.8/32", "192.0.0.9/32", "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32", "192.0.2.0/24",
 88       "192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24", "224.0.0.0/4", "100.64.0.0/10",
 89       "192.175.48.0/24","198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "240.0.0.0/4", "::1", "FE80::/10",
 90       "FF00::/8", "172.31.0.0/16"
 91       ) or
 92       process.executable in (
 93        "/usr/lib64/firefox/firefox", "/usr/lib/firefox/firefox", "/opt/forticlient/fortitraylauncher"
 94       )
 95     )
 96  ]
 97'''
 98
 99[[rule.threat]]
100framework = "MITRE ATT&CK"
101
102[[rule.threat.technique]]
103id = "T1547"
104name = "Boot or Logon Autostart Execution"
105reference = "https://attack.mitre.org/techniques/T1547/"
106
107[[rule.threat.technique.subtechnique]]
108id = "T1547.013"
109name = "XDG Autostart Entries"
110reference = "https://attack.mitre.org/techniques/T1547/013/"
111
112[rule.threat.tactic]
113id = "TA0003"
114name = "Persistence"
115reference = "https://attack.mitre.org/tactics/TA0003/"

References

Related rules

to-top