Curl SOCKS Proxy Activity from Unusual Parent
This rule detects the use of the curl
command-line tool with SOCKS proxy options, launched from an unusual parent
process. Attackers may use curl
to establish a SOCKS proxy connection to bypass network restrictions and exfiltrate
data or communicate with C2 servers.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/11/04"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2025/01/15"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule detects the use of the `curl` command-line tool with SOCKS proxy options, launched from an unusual parent
11process. Attackers may use `curl` to establish a SOCKS proxy connection to bypass network restrictions and exfiltrate
12data or communicate with C2 servers.
13"""
14from = "now-9m"
15index = ["logs-endpoint.events.*"]
16language = "eql"
17license = "Elastic License v2"
18name = "Curl SOCKS Proxy Activity from Unusual Parent"
19risk_score = 21
20rule_id = "734239fe-eda8-48c0-bca8-9e3dafd81a88"
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 "Resources: Investigation Guide",
67]
68timestamp_override = "event.ingested"
69type = "eql"
70query = '''
71process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
72process.name == "curl" and (
73 process.parent.executable like (
74 "/dev/shm/*", "/tmp/*", "/var/tmp/*", "/var/run/*", "/root/*", "/boot/*", "/var/www/html/*", "/opt/.*"
75 ) or
76 process.parent.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish")
77) and (
78 process.args like ("--socks5-hostname", "--proxy", "--preproxy", "socks5*") or
79 process.args == "-x" or
80 process.env_vars like ("http_proxy=socks5h://*", "HTTPS_PROXY=socks5h://*", "ALL_PROXY=socks5h://*")
81)
82'''
83note = """## Triage and analysis
84
85> **Disclaimer**:
86> 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.
87
88### Investigating Curl SOCKS Proxy Activity from Unusual Parent
89
90Curl is a versatile command-line tool used for transferring data with URLs, often employed for legitimate data retrieval. However, adversaries can exploit its SOCKS proxy capabilities to bypass network restrictions, facilitating covert data exfiltration or communication with command and control servers. The detection rule identifies suspicious curl executions initiated by atypical parent processes, such as those from temporary directories or shell environments, combined with SOCKS proxy arguments, indicating potential misuse.
91
92### Possible investigation steps
93
94- Review the parent process details to understand the context of the curl execution, focusing on unusual directories like /dev/shm, /tmp, or shell environments such as bash or zsh.
95- Examine the command-line arguments used with curl, specifically looking for SOCKS proxy options like --socks5-hostname or -x, to determine the intent and destination of the network request.
96- Investigate the environment variables set for the process, such as http_proxy or HTTPS_PROXY, to identify any proxy configurations that might indicate an attempt to bypass network restrictions.
97- Check the user account associated with the process execution to determine if it aligns with expected behavior or if it might be compromised.
98- Analyze network logs to trace the destination IP addresses or domains contacted via the SOCKS proxy to assess if they are known malicious or suspicious entities.
99- Correlate this activity with other alerts or logs from the same host to identify any patterns or additional indicators of compromise.
100
101### False positive analysis
102
103- Development environments may frequently use curl with SOCKS proxy options for legitimate testing purposes. To manage this, consider excluding specific development directories or user accounts from the rule.
104- Automated scripts or cron jobs running from shell environments might use curl with SOCKS proxies for routine data retrieval. Identify these scripts and exclude their parent processes or specific arguments from triggering the rule.
105- System administrators might use curl with SOCKS proxies for network diagnostics or maintenance tasks. Document these activities and create exceptions for known administrative accounts or specific command patterns.
106- Web applications hosted in directories like /var/www/html may use curl for backend operations involving SOCKS proxies. Review these applications and whitelist their specific processes or arguments if they are verified as non-threatening.
107- Temporary directories such as /tmp or /dev/shm might be used by legitimate software for transient operations involving curl. Monitor these occurrences and exclude known benign software from the rule.
108
109### Response and remediation
110
111- Immediately isolate the affected host from the network to prevent further data exfiltration or communication with command and control servers.
112- Terminate any suspicious curl processes identified by the detection rule to halt potential malicious activity.
113- Conduct a forensic analysis of the affected system to identify any additional indicators of compromise, such as unauthorized file modifications or additional malicious processes.
114- Review and clean up any unauthorized or suspicious files in temporary directories or other unusual locations, such as /dev/shm, /tmp, or /var/tmp, to remove potential threats.
115- Reset credentials and review access logs for any accounts that may have been compromised or used in conjunction with the detected activity.
116- Implement network monitoring to detect and block any further attempts to use SOCKS proxy connections from unauthorized sources.
117- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if broader organizational impacts exist."""
118
119[[rule.threat]]
120framework = "MITRE ATT&CK"
121
122[[rule.threat.technique]]
123id = "T1572"
124name = "Protocol Tunneling"
125reference = "https://attack.mitre.org/techniques/T1572/"
126
127[rule.threat.tactic]
128id = "TA0011"
129name = "Command and Control"
130reference = "https://attack.mitre.org/tactics/TA0011/"
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 Curl SOCKS Proxy Activity from Unusual Parent
Curl is a versatile command-line tool used for transferring data with URLs, often employed for legitimate data retrieval. However, adversaries can exploit its SOCKS proxy capabilities to bypass network restrictions, facilitating covert data exfiltration or communication with command and control servers. The detection rule identifies suspicious curl executions initiated by atypical parent processes, such as those from temporary directories or shell environments, combined with SOCKS proxy arguments, indicating potential misuse.
Possible investigation steps
- Review the parent process details to understand the context of the curl execution, focusing on unusual directories like /dev/shm, /tmp, or shell environments such as bash or zsh.
- Examine the command-line arguments used with curl, specifically looking for SOCKS proxy options like --socks5-hostname or -x, to determine the intent and destination of the network request.
- Investigate the environment variables set for the process, such as http_proxy or HTTPS_PROXY, to identify any proxy configurations that might indicate an attempt to bypass network restrictions.
- Check the user account associated with the process execution to determine if it aligns with expected behavior or if it might be compromised.
- Analyze network logs to trace the destination IP addresses or domains contacted via the SOCKS proxy to assess if they are known malicious or suspicious entities.
- Correlate this activity with other alerts or logs from the same host to identify any patterns or additional indicators of compromise.
False positive analysis
- Development environments may frequently use curl with SOCKS proxy options for legitimate testing purposes. To manage this, consider excluding specific development directories or user accounts from the rule.
- Automated scripts or cron jobs running from shell environments might use curl with SOCKS proxies for routine data retrieval. Identify these scripts and exclude their parent processes or specific arguments from triggering the rule.
- System administrators might use curl with SOCKS proxies for network diagnostics or maintenance tasks. Document these activities and create exceptions for known administrative accounts or specific command patterns.
- Web applications hosted in directories like /var/www/html may use curl for backend operations involving SOCKS proxies. Review these applications and whitelist their specific processes or arguments if they are verified as non-threatening.
- Temporary directories such as /tmp or /dev/shm might be used by legitimate software for transient operations involving curl. Monitor these occurrences and exclude known benign software from the rule.
Response and remediation
- Immediately isolate the affected host from the network to prevent further data exfiltration or communication with command and control servers.
- Terminate any suspicious curl processes identified by the detection rule to halt potential malicious activity.
- Conduct a forensic analysis of the affected system to identify any additional indicators of compromise, such as unauthorized file modifications or additional malicious processes.
- Review and clean up any unauthorized or suspicious files in temporary directories or other unusual locations, such as /dev/shm, /tmp, or /var/tmp, to remove potential threats.
- Reset credentials and review access logs for any accounts that may have been compromised or used in conjunction with the detected activity.
- Implement network monitoring to detect and block any further attempts to use SOCKS proxy connections from unauthorized sources.
- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if broader organizational impacts exist.
Related rules
- AWS CLI Command with Custom Endpoint URL
- IPv4/IPv6 Forwarding Activity
- Linux SSH X11 Forwarding
- Network Activity Detected via Kworker
- Network Activity Detected via cat