Curl SOCKS Proxy Detected via Elastic Defend for Containers
Attackers utilize the `curl` command-line tool with SOCKS proxy options inside Linux containers to bypass network restrictions, enabling command and control communications or data exfiltration, which defenders can detect by monitoring process execution within container environments for suspicious `curl` arguments and network tunneling activity.
This threat brief details the use of the curl command-line tool with SOCKS proxy options within Linux container environments by attackers. This technique is employed to establish covert communication channels, bypass network egress filtering, facilitate data exfiltration, or maintain command and control (C2) over compromised systems. The detection, provided by Elastic Defend for Containers, focuses on identifying curl invocations that include specific arguments such as --socks5-hostname, --proxy, --preproxy, or -x combined with a SOCKS prefix. This activity signifies an operator, having gained initial shell access to a container, is attempting to tunnel traffic to external endpoints, fetch additional payloads, or transmit stolen data through an established SOCKS proxy, potentially set up via precursor tools like ssh -D, chisel, or tor.
Attack Chain
- Initial Access: An attacker gains initial access to a Linux container, typically through a vulnerable application, misconfiguration, or stolen credentials, leading to shell access within the container.
- Environment Reconnaissance: The attacker performs reconnaissance within the compromised container to identify network capabilities, installed tools, and potential egress paths.
- Tunneling Setup: The attacker deploys and configures a tunneling tool, such as
ssh -D,chisel,cloudflared,tor, or3proxy, to establish a SOCKS proxy listener within the container or on the host. - Local Proxy Establishment: The chosen tunneling mechanism creates a local SOCKS proxy, often listening on
localhost(e.g.,localhost:1080), to facilitate redirected network traffic. - Malicious
curlExecution: The attacker executes thecurlcommand from within the container, explicitly directing it to use the locally established SOCKS proxy via options like-x socks5h://localhost:1080or--socks5-hostname. - External C2 Communication:
curlthen uses the SOCKS tunnel to communicate with external command and control (C2) servers, receiving further instructions or sending beaconing traffic. - Data Exfiltration: The attacker utilizes
curlwith data transfer options (-d/--data,-T/--upload-file) to exfiltrate sensitive data from the compromised container through the SOCKS tunnel to an attacker-controlled destination. - Payload Fetching:
curlmay also be used to download additional malicious tools or payloads from external repositories via the SOCKS proxy, extending the attacker's presence and capabilities.
Impact
Successful exploitation allows attackers to bypass network egress controls, establish persistent command and control channels, and exfiltrate sensitive data from compromised Linux container environments. This can lead to significant data breaches, further compromise of the underlying host or other containers, and disruption of critical services. While no specific victim counts or sectors are provided, the impact can be severe for any organization heavily relying on containerized applications, as it undermines their network segmentation and security controls.
Recommendation
- Deploy the Sigma rules in this brief to your SIEM and tune for your environment.
- Ensure Elastic Defend for Containers is enabled and configured to collect process execution logs from your Linux container environments, including
process.nameandprocess.argsfields. - Investigate alerts from the
Detect Curl SOCKS Proxy Usage in Linux Containersrule by retrieving the fullcurlcommand line, identifying the SOCKS proxy host and port, and analyzing target URLs for reputation. - Examine process ancestry and related Kubernetes metadata (pod, namespace, service account, node, image) for processes identified by the
Detect Curl SOCKS Proxy Usage in Linux Containersrule to attribute the activity to a specific user or application. - Review network flows and DNS queries originating from containers flagged by the
Detect Curl SOCKS Proxy Usage in Linux Containersrule, especially traffic traversing the identified SOCKS proxy, to quantify data volume and assess destination reputation.
Detection coverage 1
Detect Curl SOCKS Proxy Usage in Linux Containers
mediumDetects the use of the 'curl' command-line tool with SOCKS proxy options inside Linux containers, indicating potential command and control or data exfiltration.
Detection queries are available on the platform. Get full rules →