Hunts & Detections

Source dated

Original query

Elastic Security · ES|QL · Elastic License 2.0

Surfaces a Linux process deleting its own executable. Check whether an installer, updater, or other expected software accounts for the activity. Elastic tags this rule with MITRE ATT&CK T1070.004 (File Deletion).

Telemetry Elastic Defend file events on Linux, with the process executable path and the path of the deleted file.

Upstream author Elastic

Copyright 2021 Elasticsearch B.V.

ES|QL
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