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/09/23"
6
7[rule]
8author = ["Elastic"]
9description = """
10Detects network connections initiated through Cross-Desktop Group (XDG) autostart entries for GNOME and XFCE-based Linux
11distributions. XDG Autostart entries can be used to execute arbitrary commands or scripts when a user logs in. This rule
12helps to identify potential malicious activity where an attacker may have modified XDG autostart scripts to establish
13persistence 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 "https://www.elastic.co/security-labs/primer-on-persistence-mechanisms",
24]
25risk_score = 47
26rule_id = "dd52d45a-4602-4195-9018-ebe0f219c273"
27setup = """## Setup
28
29This rule requires data coming in from one of the following integrations:
30- Elastic Defend
31- Auditbeat
32
33### Elastic Defend Integration Setup
34Elastic 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.
35
36#### Prerequisite Requirements:
37- Fleet is required for Elastic Defend.
38- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
39
40#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
41- Go to the Kibana home page and click "Add integrations".
42- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
43- Click "Add Elastic Defend".
44- Configure the integration name and optionally add a description.
45- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
46- 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).
47- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
48- 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.
49For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
50- Click "Save and Continue".
51- 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.
52For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
53
54### Auditbeat Setup
55Auditbeat 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.
56
57#### The following steps should be executed in order to add the Auditbeat on a Linux System:
58- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
59- 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).
60- 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).
61- 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).
62- 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).
63
64#### Custom Ingest Pipeline
65For 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).
66"""
67severity = "medium"
68tags = [
69 "Domain: Endpoint",
70 "OS: Linux",
71 "Use Case: Threat Detection",
72 "Tactic: Persistence",
73 "Data Source: Elastic Defend",
74]
75timestamp_override = "event.ingested"
76type = "eql"
77
78query = '''
79sequence by host.id, process.entity_id with maxspan=1s
80 [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and (
81 (process.parent.executable == "/usr/bin/xfce4-session") or
82 (process.executable == "/bin/sh" and process.args == "-e" and process.args == "-u" and
83 process.args == "-c" and process.args : "export GIO_LAUNCHED_DESKTOP_FILE_PID=$$;*")
84 )
85 ]
86 [network where host.os.type == "linux" and event.type == "start" and event.action == "connection_attempted" and not (
87 destination.ip == null or destination.ip == "0.0.0.0" or cidrmatch(
88 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",
89 "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",
90 "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",
91 "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",
92 "FF00::/8", "172.31.0.0/16"
93 ) or
94 process.executable in (
95 "/usr/lib64/firefox/firefox", "/usr/lib/firefox/firefox", "/opt/forticlient/fortitraylauncher"
96 )
97 )
98 ]
99'''
100
101
102[[rule.threat]]
103framework = "MITRE ATT&CK"
104[[rule.threat.technique]]
105id = "T1547"
106name = "Boot or Logon Autostart Execution"
107reference = "https://attack.mitre.org/techniques/T1547/"
108[[rule.threat.technique.subtechnique]]
109id = "T1547.013"
110name = "XDG Autostart Entries"
111reference = "https://attack.mitre.org/techniques/T1547/013/"
112
113
114
115[rule.threat.tactic]
116id = "TA0003"
117name = "Persistence"
118reference = "https://attack.mitre.org/tactics/TA0003/"
References
Related rules
- APT Package Manager Configuration File Creation
- At Job Created or Modified
- Cron Job Created or Modified
- DNF Package Manager Plugin File Creation
- Executable Bit Set for Potential Persistence Script