Detection rules › Elastic

DNS Request by Recently Created Executable

Time window
10s
Sequence by
process.parent.entity_id
Source
github.com/elastic/protections-artifacts

This rule detects DNS requests initiated by recently created executables in world/user-writable directories. Malware authors may use these requests to communicate with command and control infrastructure or to exfiltrate data from the target system.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
This rule detects DNS requests initiated by recently created executables in world/user-writable directories. Malware
authors may use these requests to communicate with command and control infrastructure or to exfiltrate data from the
target system.
"""
id = "0c393c67-6eb3-4936-ab44-b807ef8af0f7"
license = "Elastic License v2"
name = "DNS Request by Recently Created Executable"
os_list = ["linux"]
version = "1.0.3"

query = '''
sequence by process.parent.entity_id with maxspan=10s
  [file where event.type == "creation" and (
    process.name in ("curl", "wget", "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "busybox", "timeout", "env") or
    process.name like (".*", "python*", "perl*", "php*", "ruby*", "lua*", "node", "deno") or
    process.executable like (
      "./*", "/tmp/*", "/var/tmp/*", "/dev/shm/*", "/run/*", "/var/run/*", "/boot/*", "/sys/*",
      "/lost+found/*", "/proc/*", "/var/mail/*", "/var/www/*", "/home/*/*", "/root/*"
    )
  ) and
  file.path like ("/tmp/*", "/var/tmp/*", "/dev/shm/*", "/home/*/*", "/root/*", "/var/www/*") and
  not (
    file.path like (
      "/home/*/.claude/downloads/claude-*-linux-x64", "/home/*/.aimee-code/bin/aimee-code"
    ) or
    (
      process.executable like "/home/*/go/pkg/mod/golang.org/*/pkg/tool/linux_amd64/link" and
      file.path like "/tmp/go-*/exe/vuln-stats"
    ) or
    process.executable like (
      "/home/*/.local/share/claude/versions/*", "/home/*/.vscode-server/cli/servers/Stable-*/server/node",
      "/tmp/*/.vscode-server/.vscode-server/cli/servers/Stable-*/server/node", "/home/*/.vscode-server/bin/*/node"
    )
  )] as event0
  [dns where event.action == "lookup_result" and startswith~(process.executable, event0.file.path) and
  dns.question.name != "localhost"]
'''

min_endpoint_version = "9.3.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 1

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1204"
name = "User Execution"
reference = "https://attack.mitre.org/techniques/T1204/"
[[threat.technique.subtechnique]]
id = "T1204.002"
name = "Malicious File"
reference = "https://attack.mitre.org/techniques/T1204/002/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1071"
name = "Application Layer Protocol"
reference = "https://attack.mitre.org/techniques/T1071/"
[[threat.technique.subtechnique]]
id = "T1071.004"
name = "DNS"
reference = "https://attack.mitre.org/techniques/T1071/004/"


[[threat.technique]]
id = "T1102"
name = "Web Service"
reference = "https://attack.mitre.org/techniques/T1102/"


[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"

[internal]
min_endpoint_version = "9.3.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 10s, correlated by process.parent.entity_id.

Stage 1: file

[file where event.type == "creation" and (
    process.name in ("curl", "wget", "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "busybox", "timeout", "env") or
    process.name like (".*", "python*", "perl*", "php*", "ruby*", "lua*", "node", "deno") or
    process.executable like (
      "./*", "/tmp/*", "/var/tmp/*", "/dev/shm/*", "/run/*", "/var/run/*", "/boot/*", "/sys/*",
      "/lost+found/*", "/proc/*", "/var/mail/*", "/var/www/*", "/home/*/*", "/root/*"
    )
  ) and
  file.path like ("/tmp/*", "/var/tmp/*", "/dev/shm/*", "/home/*/*", "/root/*", "/var/www/*") and
  not (
    file.path like (
      "/home/*/.claude/downloads/claude-*-linux-x64", "/home/*/.aimee-code/bin/aimee-code"
    ) or
    (
      process.executable like "/home/*/go/pkg/mod/golang.org/*/pkg/tool/linux_amd64/link" and
      file.path like "/tmp/go-*/exe/vuln-stats"
    ) or
    process.executable like (
      "/home/*/.local/share/claude/versions/*", "/home/*/.vscode-server/cli/servers/Stable-*/server/node",
      "/tmp/*/.vscode-server/.vscode-server/cli/servers/Stable-*/server/node", "/home/*/.vscode-server/bin/*/node"
    )
  )] as event0

Stage 2: dns

[dns where event.action == "lookup_result" and startswith~(process.executable, event0.file.path) and
  dns.question.name != "localhost"]

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
file.pathwildcard/tmp/go-*/exe/vuln-statsexcludes:file.path field:"file.path" value:"/tmp/go-*/exe/vuln-stats"
process.executablewildcard/home/*/go/pkg/mod/golang.org/*/pkg/tool/linux_amd64/linkexcludes:process.executable field:"process.executable" value:"/home/*/go/pkg/mod/golang.org/*/pkg/tool/linux_amd64/link"
file.pathwildcard/home/*/.claude/downloads/claude-*-linux-x64, /home/*/.aimee-code/bin/aimee-codeexcludes:file.path field:"file.path" value:"/home/*/.claude/downloads/claude-*-linux-x64" field:"file.path" value:"/home/*/.aimee-code/bin/aimee-code"
process.executablewildcard/home/*/.local/share/claude/versions/*, /home/*/.vscode-server/cli/servers/Stable-*/server/node, /tmp/*/.vscode-server/.vscode-server/cli/servers/Stable-*/server/node, /home/*/.vscode-server/bin/*/nodeexcludes:process.executable

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
dns.question.namene
  • localhost
field:"QueryName" kind:ne value:"localhost"
event.actioneq
  • lookup_result
field:"EventType" kind:eq value:"lookup_result"
event.typeeq
  • creation
field:"event.type" kind:eq value:"creation"
file.pathwildcard
  • /dev/shm/*
  • /home/*/*
  • /root/*
  • /tmp/*
  • /var/tmp/*
  • /var/www/*
field:"TargetFilename" kind:wildcard
process.executablestarts_with
  • event0.file.path (field reference)
field:"Image" kind:starts_with value:"event0.file.path"
process.executablewildcard
  • ./*
  • /boot/*
  • /dev/shm/*
  • /home/*/*
  • /lost+found/*
  • /proc/*
  • /root/*
  • /run/*
  • /sys/*
  • /tmp/*
  • /var/mail/*
  • /var/run/*
  • /var/tmp/*
  • /var/www/*
field:"Image" kind:wildcard
process.namein
  • bash
  • busybox
  • csh
  • curl
  • dash
  • env
  • fish
  • ksh
  • sh
  • tcsh
  • timeout
  • wget
  • zsh
field:"process_name" kind:in
process.namewildcard
  • .*
  • deno
  • lua*
  • node
  • perl*
  • php*
  • python*
  • ruby*
field:"process_name" kind:wildcard