Detection rules › Elastic
Node Script Execution and Immediate Deletion
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
| Tactic | Techniques |
|---|---|
| Stealth |
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.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
file.path | wildcard | /tmp/github-runner-*/index.js, /root/setup-pnpm/node_modules/.pnpm/pnpm@*/node_modules/pnpm/dist/node_modules/env-paths/index.js | excludes: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.executable | eq | /actions-runner/externals/node24/bin/node | excludes:process.executable field:"process.executable" value:"/actions-runner/externals/node24/bin/node" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"deletion" |
event.action | in |
| field:"EventType" kind:in |
event.type | eq |
| field:"event.type" kind:eq value:"start" |
event0.process.command_line | contains |
| field:"event0.process.command_line" kind:contains value:"file.name" |
file.extension | wildcard |
| field:"file.extension" kind:wildcard value:"js" |
process.args | wildcard |
| field:"process.args" kind:wildcard |
process.args_count | le |
| field:"process.args_count" kind:le value:"2" |
process.name | in |
| field:"process_name" kind:in |