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

Potential Process Self-Deletion

edit

Detects a Linux process deleting its own executable from a relative, temporary, shared-memory, system, web, or user directory. Adversaries may self-delete payloads after execution to remove artifacts and hinder forensic analysis.

Rule type: esql

Rule indices: None

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: Defense Evasion
  • Data Source: Elastic Defend
  • Resources: Investigation Guide
  • Rule Type: ES|QL
  • Platform: Linux

Version: 1

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 Potential Process Self-Deletion

This rule identifies a file deletion event where the deleted path matches the executable of the process responsible for the deletion. Self-deleting executables are often used by malware to remove payloads after execution and reduce forensic evidence.

Possible investigation steps

  • Review the process executable, command line, user, parent process, and ancestor chain to determine how the executable was launched.
  • Examine the deleted file’s hash, path, creation time, and any available file metadata, and search for the same artifact on other hosts.
  • Correlate nearby process, file, network, and authentication events to identify payload delivery, persistence, command-and-control, or lateral movement.
  • If the process is still running, preserve volatile evidence such as /proc/<pid>/exe, memory, open file descriptors, and active network connections before containment.

False positive analysis

  • Legitimate installers, updaters, deployment tools, and temporary application launchers may remove their own executable after completing. Validate the process lineage, user context, file hash, and change records before adding exceptions.
  • Software running from user-writable or temporary directories can produce this behavior during normal cleanup. Confirm that the executable and its parent are trusted and that no suspicious follow-on activity occurred.

Response and remediation

  • Isolate the host when the executable or process lineage is untrusted, and preserve volatile evidence before terminating the process.
  • Quarantine related artifacts, remove persistence, and block identified hashes, domains, IP addresses, or download sources.
  • Determine the initial access vector, rotate exposed credentials, and hunt for the same executable, hash, or behavior across the environment.
  • Reimage or restore the host from a known-good source if system integrity cannot be established.

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 select "Add integrations".
  • Search for "Elastic Defend" and select the integration.
  • Select "Add Elastic Defend".
  • Configure the integration and select a policy that collects all events, such as "Complete EDR (Endpoint Detection and Response)".
  • Save the integration and install Elastic Agent on the Linux hosts to monitor.

Rule query

edit
FROM logs-endpoint.events.file-* METADATA _id, _index, _version
| WHERE KQL("""host.os.type:linux and event.category:file and event.type:deletion and event.action:deletion""")
    AND process.executable IS NOT NULL
    AND file.path IS NOT NULL
    // Require an exact, case-sensitive match between the deleting process executable and the deleted file.
    AND process.executable == file.path
    AND (
      process.executable LIKE "./*"
      OR process.executable LIKE "/tmp/*"
      OR process.executable LIKE "/var/tmp/*"
      OR process.executable LIKE "/dev/shm/*"
      OR process.executable LIKE "/run/*"
      OR process.executable LIKE "/var/run/*"
      OR process.executable LIKE "/boot/*"
      OR process.executable LIKE "/sys/*"
      OR process.executable LIKE "/lost+found/*"
      OR process.executable LIKE "/proc/*"
      OR process.executable LIKE "/var/mail/*"
      OR process.executable LIKE "/var/www/*"
      OR process.executable LIKE "/home/*/*"
      OR process.executable LIKE "/root/*"
    )
| KEEP
    @timestamp,
    _id,
    _index,
    _version,
    host.id,
    host.name,
    user.id,
    user.name,
    file.path,
    file.name,
    file.hash.sha256,
    process.entity_id,
    process.pid,
    process.name,
    process.executable,
    process.parent.entity_id

Framework: MITRE ATT&CKTM