Linux Interpreter Downloads and Pipes Payload for Execution
This detection rule targets a Linux defense evasion technique where an interpreter downloads a malicious payload from an external address and immediately pipes its content into another interpreter for in-memory execution, allowing attackers to establish persistence, exfiltrate data, or run stagers without writing files to disk.
This brief describes a detection rule focused on a Linux execution and defense evasion technique where attackers leverage native interpreters to download and execute payloads without writing them to disk. The method involves an interpreter, such as Python or a shell, initiating an outbound network connection to fetch a malicious script or binary. The downloaded content is then directly streamed (piped) as input to another interpreter, like sh or bash, which executes it in memory. This technique allows adversaries to bypass file-based defenses, maintain a low footprint, and blend with legitimate administrative activities. Attackers utilize this for various malicious purposes including establishing persistence, exfiltrating sensitive data, or executing in-memory stagers for further compromise, making it a critical behavior to detect on Linux endpoints.
Attack Chain
- An initial interpreter process (e.g.,
python,bash,perl,curl,wgetimplicitly via a shell command) establishes an outbound network connection to a remote, external IP address. - The interpreter downloads a malicious payload, which can be a script or raw binary data.
- Instead of saving the payload to disk, its output stream is immediately piped as standard input to a second interpreter process (e.g.,
sh,bash,python). - The second interpreter executes the received content directly in memory, often indicated by a command line argument like
sh -orbash -. - This in-memory execution often involves a stager script designed to download subsequent stages of malware or establish initial access.
- The ultimately executed payload can then perform actions such as establishing persistence, escalating privileges, conducting lateral movement, or exfiltrating data.
Impact
Successful exploitation using this technique can lead to significant compromise of Linux systems. Attackers can gain persistent access to compromised hosts, escalate privileges, exfiltrate sensitive data, and pivot to other systems within the network. Since the payloads are executed in memory, forensic analysis can be more challenging, potentially delaying detection and response. The impact can range from data breaches and service disruption to complete system control, depending on the attacker's objectives and the nature of the executed payload.
Recommendation
- Deploy the Sigma rule provided in this brief to your SIEM and tune for your environment to detect interpreters receiving piped input.
- Configure Elastic Defend integration to collect
process_creationandnetwork_connectionlogs from all Linux endpoints, as required by the detection rule. - Monitor outbound network connections from interpreters using
network_connectionlogs, especially to unusual or untrusted external destinations. - Audit and reconstruct the full process lineage and execution context from
process_creationlogs for any alerts generated by the rule to distinguish legitimate automation from malicious activity. - Implement strong egress filtering to restrict direct internet access from interpreters and server applications, allowing connections only to approved package mirrors and script repositories.
Detection coverage 1
Detect Linux Interpreter Receiving Piped Input
mediumDetects Linux interpreters launched with arguments indicating they are receiving input via a pipe, a common technique for executing downloaded payloads directly in memory for defense evasion.
Detection queries are available on the platform. Get full rules →