Detection rules › Elastic
Suspicious Remote Javascript Evaluation via Nodejs
Detects when Node.js makes an outbound network connection followed immediately by the command line evaluation of JavaScript. Threat actors will host a remote JavaScript payload that will be fetched and executed via the Node.js evaluate flag.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution |
Telemetry coverage
Rule body
[rule]
description = """
Detects when Node.js makes an outbound network connection followed immediately by the command line evaluation of
JavaScript. Threat actors will host a remote JavaScript payload that will be fetched and executed via the Node.js
evaluate flag.
"""
id = "57bb41f8-091f-42d5-9eaf-588dfa32d7e3"
license = "Elastic License v2"
name = "Suspicious Remote Javascript Evaluation via Nodejs"
os_list = ["macos"]
reference = ["https://kl4r10n.tech/blog/dprk-new-malware"]
version = "1.0.5"
query = '''
sequence with maxspan=20s
[network where event.action == "connection_attempted" and process.name == "node" and
not destination.domain in ("registry.npmjs.org", "classic.yarnpkg.com", "platform.claude.com", "api.anthropic.com", "registry.yarnpkg.com", "api.z.ai",
"telemetry.nuxt.com", "api.fontshare.com", "yarnpkg.com", "telemetry-staging.elastic.co", "elastic.litellm-prod.ai",
"chatgpt.com", "bedrock-runtime.us-east-1.amazonaws.com")] by process.entity_id
[process where event.type == "start" and event.action == "exec" and process.name == "node" and
process.args == "-e" and process.args_count == 3 and
not process.command_line : ("*try*require*postinstall*catch*", "*import*postinstall*catch*")] by process.parent.entity_id
'''
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
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.007"
name = "JavaScript"
reference = "https://attack.mitre.org/techniques/T1059/007/"
[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[internal]
min_endpoint_version = "8.16.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 20s, correlated by process.entity_id, process.parent.entity_id.
Stage 1: network
[network where event.action == "connection_attempted" and process.name == "node" and
not destination.domain in ("registry.npmjs.org", "classic.yarnpkg.com", "platform.claude.com", "api.anthropic.com", "registry.yarnpkg.com", "api.z.ai",
"telemetry.nuxt.com", "api.fontshare.com", "yarnpkg.com", "telemetry-staging.elastic.co", "elastic.litellm-prod.ai",
"chatgpt.com", "bedrock-runtime.us-east-1.amazonaws.com")] by process.entity_id
Stage 2: process
[process where event.type == "start" and event.action == "exec" and process.name == "node" and
process.args == "-e" and process.args_count == 3 and
not process.command_line : ("*try*require*postinstall*catch*", "*import*postinstall*catch*")] by process.parent.entity_id
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
destination.domain | in | api.anthropic.com, api.fontshare.com, api.z.ai, bedrock-runtime.us-east-1.amazonaws.com, chatgpt.com, classic.yarnpkg.com, elastic.litellm-prod.ai, platform.claude.com, registry.npmjs.org, registry.yarnpkg.com, telemetry-staging.elastic.co, telemetry.nuxt.com, yarnpkg.com | excludes:destination.domain |
process.command_line | wildcard | *try*require*postinstall*catch*, *import*postinstall*catch* | excludes:process.command_line field:"process.command_line" value:"*try*require*postinstall*catch*" field:"process.command_line" value:"*import*postinstall*catch*" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq |
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.args | eq |
| field:"process.args" kind:eq value:"-e" |
process.args_count | eq |
| field:"process.args_count" kind:eq value:"3" |
process.name | eq |
| field:"process_name" kind:eq value:"node" |