Detection rules › Elastic

Node Script Execution and Immediate Deletion

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

Detects Node.js executing a JavaScript file followed by immediate deletion of that script. This anti-forensics pattern is used to execute malicious logic and then destroy the evidence, making post-incident inspection difficult. The tight timing window between execution and deletion distinguishes this from normal cleanup or build processes.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Detects Node.js executing a JavaScript file followed by immediate deletion of that script. This anti-forensics pattern
is used to execute malicious logic and then destroy the evidence, making post-incident inspection difficult. The tight
timing window between execution and deletion distinguishes this from normal cleanup or build processes.
"""
id = "1059825f-8f64-4b69-a398-2a54003d1946"
license = "Elastic License v2"
name = "Node Script Execution and Immediate Deletion"
os_list = ["linux", "windows"]
reference = ["https://www.elastic.co/security-labs/axios-supply-chain-compromise-detections"]
version = "1.0.2"

query = '''
sequence by process.entity_id with maxspan=10s
  [process where event.type == "start" and event.action in ("exec", "start") and
    process.name in ("node", "node.exe") and process.args_count <= 2 and
    process.args like~ (
      "/tmp/*.js", "/private/tmp/*.js",
      "/var/tmp/*.js", "/private/var/tmp/*.js",
      "/Users/Shared/*.js",
      "/var/folders/*/T/*.js", "/private/var/folders/*/T/*.js",
      "/Users/*/Library/Caches/*.js",
      "/dev/shm/*.js",
      "?:\\\\Users\\\\*\\\\AppData\\\\Local\\\\Temp\\\\*.js",
      "?:\\\\Windows\\\\Temp\\\\*.js",
      "?:\\\\ProgramData\\\\Temp\\\\*.js"
    )] as event0
  [file where event.action == "deletion" and file.extension : "js" and
   stringcontains~(event0.process.command_line, file.name) and
   not (
     process.executable like "/actions-runner/externals/node24/bin/node" and
     file.path like (
       "/tmp/github-runner-*/index.js",
       "/root/setup-pnpm/node_modules/.pnpm/pnpm@*/node_modules/pnpm/dist/node_modules/env-paths/index.js"
     )
   )]
'''

min_endpoint_version = "8.16.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 = "T1070"
name = "Indicator Removal"
reference = "https://attack.mitre.org/techniques/T1070/"
[[threat.technique.subtechnique]]
id = "T1070.004"
name = "File Deletion"
reference = "https://attack.mitre.org/techniques/T1070/004/"



[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "8.16.0"

Stages and Predicates

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

Stage 1: process

[process where event.type == "start" and event.action in ("exec", "start") and
    process.name in ("node", "node.exe") and process.args_count <= 2 and
    process.args like~ (
      "/tmp/*.js", "/private/tmp/*.js",
      "/var/tmp/*.js", "/private/var/tmp/*.js",
      "/Users/Shared/*.js",
      "/var/folders/*/T/*.js", "/private/var/folders/*/T/*.js",
      "/Users/*/Library/Caches/*.js",
      "/dev/shm/*.js",
      "?:\\\\Users\\\\*\\\\AppData\\\\Local\\\\Temp\\\\*.js",
      "?:\\\\Windows\\\\Temp\\\\*.js",
      "?:\\\\ProgramData\\\\Temp\\\\*.js"
    )] as event0

Stage 2: file

[file where event.action == "deletion" and file.extension : "js" and
   stringcontains~(event0.process.command_line, file.name) and
   not (
     process.executable like "/actions-runner/externals/node24/bin/node" and
     file.path like (
       "/tmp/github-runner-*/index.js",
       "/root/setup-pnpm/node_modules/.pnpm/pnpm@*/node_modules/pnpm/dist/node_modules/env-paths/index.js"
     )
   )]

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
file.pathwildcard/tmp/github-runner-*/index.js, /root/setup-pnpm/node_modules/.pnpm/pnpm@*/node_modules/pnpm/dist/node_modules/env-paths/index.jsexcludes:file.path field:"file.path" value:"/tmp/github-runner-*/index.js" field:"file.path" value:"/root/setup-pnpm/node_modules/.pnpm/pnpm@*/node_modules/pnpm/dist/node_modules/env-paths/index.js"
process.executableeq/actions-runner/externals/node24/bin/nodeexcludes:process.executable field:"process.executable" value:"/actions-runner/externals/node24/bin/node"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • deletion corpus 12 (elastic 12)
field:"EventType" kind:eq value:"deletion"
event.actionin
  • exec corpus 576 (elastic 561, sigma 15)
  • start corpus 391 (elastic 391)
field:"EventType" kind:in
event.typeeq
  • start corpus 1078 (elastic 1078)
field:"event.type" kind:eq value:"start"
event0.process.command_linecontains
  • file.name (field reference) corpus 4 (elastic 4)
field:"event0.process.command_line" kind:contains value:"file.name"
file.extensionwildcard
  • js corpus 23 (elastic 23)
field:"file.extension" kind:wildcard value:"js"
process.argswildcard
  • /Users/*/Library/Caches/*.js corpus 2 (elastic 2)
  • /Users/Shared/*.js corpus 2 (elastic 2)
  • /dev/shm/*.js corpus 3 (elastic 3)
  • /private/tmp/*.js corpus 2 (elastic 2)
  • /private/var/folders/*/T/*.js corpus 2 (elastic 2)
  • /private/var/tmp/*.js corpus 2 (elastic 2)
  • /tmp/*.js corpus 3 (elastic 3)
  • /var/folders/*/T/*.js corpus 2 (elastic 2)
  • /var/tmp/*.js corpus 3 (elastic 3)
  • ?:\\ProgramData\\Temp\\*.js corpus 2 (elastic 2)
  • ?:\\Users\\*\\AppData\\Local\\Temp\\*.js corpus 2 (elastic 2)
  • ?:\\Windows\\Temp\\*.js corpus 2 (elastic 2)
field:"process.args" kind:wildcard
process.args_countle
  • 2 transforms: number corpus 17 (elastic 17)
field:"process.args_count" kind:le value:"2"
process.namein
  • node corpus 25 (elastic 25)
  • node.exe corpus 6 (elastic 6)
field:"process_name" kind:in