Payload Downloaded by Interpreter and Piped to Interpreter

edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.

Payload Downloaded by Interpreter and Piped to Interpreter

edit

This rule detects when a payload is downloaded by an interpreter, 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.

Rule type: eql

Rule indices:

  • logs-endpoint.events.network*
  • logs-endpoint.events.process*

Severity: medium

Risk score: 47

Runs every: 5m

Searches indices from: now-9m (Date Math format, see also Additional look-back time)

Maximum alerts per execution: 100

References: None

Tags:

  • Domain: Endpoint
  • OS: Linux
  • Use Case: Threat Detection
  • Tactic: Execution
  • Tactic: Command and Control
  • Tactic: Defense Evasion
  • Data Source: Elastic Defend
  • Resources: Investigation Guide

Version: 2

Rule authors:

  • Elastic

Rule license: Elastic License v2

Investigation guide

edit

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 Payload Downloaded by Interpreter and Piped to Interpreter

This rule flags a Linux interpreter that reaches out to an external address and then immediately starts another interpreter with no script argument, a strong sign that downloaded content is being fed directly into code execution. Attackers use this to avoid writing files and blend into admin activity, for example by having Python fetch a remote shell script with urllib and pipe the response into sh or bash to run a stager in memory.

Possible investigation steps

  • Reconstruct the full process lineage and execution context, including the initiating user, shell history, service unit, cron job, container entrypoint, or remote session that triggered the download-and-execute chain, to distinguish sanctioned automation from attacker activity.
  • Validate the remote endpoint by reviewing DNS, proxy, HTTP/TLS, and reputation data for the contacted infrastructure and compare it with known package mirrors, internal tooling, and recent maintenance activity to quickly identify likely benign installers versus suspicious staging hosts.
  • Attempt to recover the downloaded payload from proxy caches, packet capture, endpoint telemetry, memory, or command history and analyze its behavior to determine whether it is a legitimate bootstrap script or a stager that enables persistence, credential theft, or additional downloads.
  • Investigate post-alert activity on the host for concrete follow-on actions such as writes to temporary or startup locations, cron or systemd persistence, new accounts, SSH key changes, privilege escalation, lateral movement tooling, or security-control tampering.
  • If the activity cannot be confidently tied to approved administration, isolate the system and pivot across the environment for the same parent-child lineage, remote infrastructure, script fragments, and resulting artifacts to scope impact and block recurrence.

False positive analysis

  • Legitimate provisioning or maintenance on a Linux host may use a shell or Python one-liner to download an installation or update script from an approved external repository and pipe it to sh or bash; verify the parent process aligns with a known admin action or change window and that the destination and script content match an approved baseline.
  • Scheduled automation can trigger this when a service account or system task fetches a small bootstrap script from a sanctioned internet endpoint and feeds it directly to an interpreter during deployment or configuration refresh; verify it was started by the expected cron or systemd context and that the same process lineage and destination recur consistently across managed hosts.

Response and remediation

  • Isolate the affected Linux host from the network while preserving forensic access, stop the active interpreter chain, and block the contacted external IPs, domains, and download URLs at egress controls to prevent reinfection.
  • Remove attacker footholds created by the downloaded script, including malicious cron entries, systemd services or timers, /etc/rc.local changes, shell profile modifications, unauthorized authorized_keys entries, and payloads dropped in /tmp, /var/tmp, /dev/shm, or user home directories.
  • Revoke access the payload may have exposed by resetting passwords, rotating SSH keys, API tokens, and application secrets present on the host, and disabling any unauthorized local or service accounts created during the intrusion.
  • Restore the host to a known-good state by rebuilding or reimaging from a trusted baseline or verified backup, applying current security patches, and validating that only approved packages, startup items, and scheduled tasks remain before reconnecting it to production.
  • Escalate to incident response immediately if the script executed as root, the same download source or script fragment appears on multiple hosts, authentication material was accessed or modified, or you observe follow-on behaviors such as lateral movement, data staging, or persistent outbound beaconing.
  • Harden the environment by restricting direct internet access from interpreters and automation accounts, allowlisting approved package mirrors and script repositories, enforcing least privilege for service users, and alerting on future curl or wget to shell and interpreter-to-interpreter execution patterns.

Setup

edit

Setup

This rule requires data coming in from Elastic Defend.

Elastic Defend Integration Setup

Elastic 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.

Prerequisite Requirements:

  • Fleet is required for Elastic Defend.
  • To configure Fleet Server refer to the documentation.

The following steps should be executed in order to add the Elastic Defend integration on a Linux System:

  • Go to the Kibana home page and click "Add integrations".
  • In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
  • Click "Add Elastic Defend".
  • Configure the integration name and optionally add a description.
  • Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
  • 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.
  • We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
  • 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. For more details on Elastic Agent configuration settings, refer to the helper guide.
  • Click "Save and Continue".
  • 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. For more details on Elastic Defend refer to the helper guide.

Rule query

edit
sequence by host.id, process.parent.entity_id, process.working_directory with maxspan=1s
  [network where host.os.type == "linux" and event.type == "start" and event.action == "connection_attempted" and (
    process.name like (
      "bash", "dash", "sh", "tcsh", "tclsh", "wish", "csh", "zsh", "ksh", "fish",
      "mksh", "busybox", "rscript", "r", "julia", "mono", "dotnet", "groovy", "kotlin",
      "scala", "erlang", "escript", "ocaml", "ocamlopt", "ld.so", "ld-linux-x86-64.so.2",
      "ld-musl-x86_64.so.1", "awk", "gawk", "mawk", "nawk", "node", "nodejs", "deno",
      "env", "timeout", "nice", "stdbuf", "setsid", "setarch", "unshare", "nsenter", "flock",
      "runuser", "sudo", "snap"
    ) or
    process.name like ("python*", "perl*", "ruby*", "lua*", "php*", "qemu-*-static")
  ) and
   not (destination.ip == null or destination.ip == "0.0.0.0" or cidrmatch(
     destination.ip, "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.0.0/29",
     "192.0.0.8/32", "192.0.0.9/32", "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32", "192.0.2.0/24",
     "192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24", "224.0.0.0/4", "100.64.0.0/10",
     "192.175.48.0/24","198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "240.0.0.0/4", "::1", "FE80::/10",
     "FF00::/8"
     )
   )]
  [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and (
    process.name like (
      "bash", "dash", "sh", "tcsh", "tclsh", "wish", "csh", "zsh", "ksh", "fish",
      "mksh", "busybox", "rscript", "r", "julia", "mono", "dotnet", "groovy", "kotlin",
      "scala", "erlang", "escript", "ocaml", "ocamlopt", "ld.so", "ld-linux-x86-64.so.2",
      "ld-musl-x86_64.so.1", "awk", "gawk", "mawk", "nawk", "node", "nodejs", "deno"
    ) or
    process.name like ("python*", "perl*", "ruby*", "lua*", "php*")
  ) and (
    stringcontains(process.executable, process.command_line) or
    stringcontains(process.name, process.command_line)
  ) and
  process.args_count == 1]

Framework: MITRE ATT&CKTM