Node Script Execution and Immediate Deletion
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.
Query · eql
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"
)
)]