Git Repository or File Download to Suspicious Directory

This rule detects the use of git to clone a repository or download files from GitHub using wget or curl, followed by the creation of files in suspicious directories such as /tmp, /var/tmp, or /dev/shm. This behavior may indicate an attempt to download a payload, exploit or tool.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2025/04/25"
 3integration = ["endpoint"]
 4maturity = "production"
 5updated_date = "2025/04/25"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10This rule detects the use of git to clone a repository or download files from GitHub using wget or curl, followed by
11the creation of files in suspicious directories such as /tmp, /var/tmp, or /dev/shm. This behavior may indicate an
12attempt to download a payload, exploit or tool.
13"""
14from = "now-9m"
15index = ["logs-endpoint.events.*"]
16language = "eql"
17license = "Elastic License v2"
18name = "Git Repository or File Download to Suspicious Directory"
19risk_score = 21
20rule_id = "70089609-c41a-438e-b132-5b3b43c5fc07"
21setup = """## Setup
22
23This rule requires data coming in from Elastic Defend.
24
25### Elastic Defend Integration Setup
26Elastic 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.
27
28#### Prerequisite Requirements:
29- Fleet is required for Elastic Defend.
30- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
31
32#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
33- Go to the Kibana home page and click "Add integrations".
34- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
35- Click "Add Elastic Defend".
36- Configure the integration name and optionally add a description.
37- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
38- 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).
39- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
40- 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.
41For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
42- Click "Save and Continue".
43- 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.
44For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
45
46Elastic Defend integration does not collect environment variable logging by default.
47In order to capture this behavior, this rule requires a specific configuration option set within the advanced settings of the Elastic Defend integration.
48 #### To set up environment variable capture for an Elastic Agent policy:
49- Go to “Security → Manage → Policies”.
50- Select an “Elastic Agent policy”.
51- Click “Show advanced settings”.
52- Scroll down or search for “linux.advanced.capture_env_vars”.
53- Enter the names of environment variables you want to capture, separated by commas.
54- For this rule the linux.advanced.capture_env_vars variable should be set to "HTTP_PROXY,HTTPS_PROXY,ALL_PROXY".
55- Click “Save”.
56After saving the integration change, the Elastic Agents running this policy will be updated and the rule will function properly.
57For more information on capturing environment variables refer to the [helper guide](https://www.elastic.co/guide/en/security/current/environment-variable-capture.html).
58"""
59severity = "low"
60tags = [
61    "Domain: Endpoint",
62    "OS: Linux",
63    "Use Case: Threat Detection",
64    "Tactic: Command and Control",
65    "Data Source: Elastic Defend",
66]
67type = "eql"
68query = '''
69sequence by process.entity_id, host.id with maxspan=10s
70  [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and (
71     (process.name == "git" and process.args == "clone") or
72     (process.name in ("wget", "curl") and process.command_line like~ "*github*")
73  )]
74  [file where host.os.type == "linux" and event.type == "creation" and file.path like ("/tmp/*", "/var/tmp/*", "/dev/shm/*")]
75'''
76
77[[rule.threat]]
78framework = "MITRE ATT&CK"
79
80[[rule.threat.technique]]
81id = "T1071"
82name = "Application Layer Protocol"
83reference = "https://attack.mitre.org/techniques/T1071/"
84
85[rule.threat.tactic]
86id = "TA0011"
87name = "Command and Control"
88reference = "https://attack.mitre.org/tactics/TA0011/"

Related rules

to-top