Skip to content

Commit a72dbb8

Browse files
[Rule Tuning] Node.js Pre or Post-Install Script Execution to Cross-Platform
Fixes #5402
1 parent d3745c2 commit a72dbb8

File tree

2 files changed

+159
-22
lines changed

2 files changed

+159
-22
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
[metadata]
2+
creation_date = "2025/09/18"
3+
integration = ["endpoint", "crowdstrike"]
4+
maturity = "production"
5+
updated_date = "2025/12/03"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
This rule detects the execution of Node.js pre or post-install scripts. These scripts are executed
11+
by the Node.js package manager (npm) during the installation of packages. Adversaries may abuse
12+
this technique to execute arbitrary commands on the system and establish persistence. This activity
13+
was observed in the wild as part of the Shai-Hulud worm.
14+
"""
15+
from = "now-9m"
16+
index = ["logs-endpoint.events.process*", "logs-crowdstrike.fdr*"]
17+
language = "eql"
18+
license = "Elastic License v2"
19+
name = "Node.js Pre or Post-Install Script Execution"
20+
references = [
21+
"https://www.elastic.co/blog/shai-hulud-worm-npm-supply-chain-compromise",
22+
"https://www.wiz.io/blog/shai-hulud-2-0-ongoing-supply-chain-attack"
23+
]
24+
risk_score = 47
25+
rule_id = "0871a5d8-6b5f-4a12-a568-fd7bc05bd8db"
26+
setup = """## Setup
27+
28+
This rule requires data coming in from Elastic Defend.
29+
30+
### Elastic Defend Integration Setup
31+
Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
32+
33+
#### Prerequisite Requirements:
34+
- Fleet is required for Elastic Defend.
35+
- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
36+
37+
#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
38+
- Go to the Kibana home page and click "Add integrations".
39+
- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
40+
- Click "Add Elastic Defend".
41+
- Configure the integration name and optionally add a description.
42+
- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
43+
- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
44+
- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
45+
- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
46+
For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
47+
- Click "Save and Continue".
48+
- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
49+
For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
50+
"""
51+
severity = "medium"
52+
tags = [
53+
"Domain: Endpoint",
54+
"OS: Linux",
55+
"OS: macOS",
56+
"Use Case: Threat Detection",
57+
"Tactic: Persistence",
58+
"Tactic: Execution",
59+
"Tactic: Defense Evasion",
60+
"Data Source: Elastic Defend",
61+
"Resources: Investigation Guide",
62+
"Data Source: Crowdstrike",
63+
]
64+
type = "eql"
65+
query = '''
66+
sequence by host.id with maxspan=10s
67+
[process where host.os.type in ("linux", "macos") and event.type == "start" and event.action in ("exec", "ProcessRollup2") and process.name == "node" and process.args == "install"] by process.entity_id
68+
[process where host.os.type in ("linux", "macos") and event.type == "start" and event.action in ("exec", "ProcessRollup2") and process.parent.name == "node"] by process.parent.entity_id
69+
'''
70+
71+
[[rule.threat]]
72+
framework = "MITRE ATT&CK"
73+
74+
[[rule.threat.technique]]
75+
id = "T1543"
76+
name = "Create or Modify System Process"
77+
reference = "https://attack.mitre.org/techniques/T1543/"
78+
79+
[[rule.threat.technique]]
80+
id = "T1574"
81+
name = "Hijack Execution Flow"
82+
reference = "https://attack.mitre.org/techniques/T1574/"
83+
84+
[rule.threat.tactic]
85+
id = "TA0003"
86+
name = "Persistence"
87+
reference = "https://attack.mitre.org/tactics/TA0003/"
88+
89+
[[rule.threat]]
90+
framework = "MITRE ATT&CK"
91+
92+
[[rule.threat.technique]]
93+
id = "T1059"
94+
name = "Command and Scripting Interpreter"
95+
reference = "https://attack.mitre.org/techniques/T1059/"
96+
97+
[[rule.threat.technique.subtechnique]]
98+
id = "T1059.004"
99+
name = "Unix Shell"
100+
reference = "https://attack.mitre.org/techniques/T1059/004/"
101+
102+
[[rule.threat.technique]]
103+
id = "T1204"
104+
name = "User Execution"
105+
reference = "https://attack.mitre.org/techniques/T1204/"
106+
107+
[[rule.threat.technique.subtechnique]]
108+
id = "T1204.005"
109+
name = "Malicious Library"
110+
reference = "https://attack.mitre.org/techniques/T1204/005/"
111+
112+
[rule.threat.tactic]
113+
id = "TA0002"
114+
name = "Execution"
115+
reference = "https://attack.mitre.org/tactics/TA0002/"
116+
117+
[[rule.threat]]
118+
framework = "MITRE ATT&CK"
119+
120+
[rule.threat.tactic]
121+
id = "TA0005"
122+
name = "Defense Evasion"
123+
reference = "https://attack.mitre.org/tactics/TA0005/"

rules/linux/persistence_nodejs_pre_or_post_install_script_execution.toml

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22
creation_date = "2025/09/18"
33
integration = ["endpoint", "crowdstrike"]
44
maturity = "production"
5-
updated_date = "2025/10/17"
5+
updated_date = "2025/12/03"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
This rule detects the execution of Node.js pre or post-install scripts. These scripts are executed
11-
by the Node.js package manager (npm) during the installation of packages. Adversaries may abuse
12-
this technique to execute arbitrary commands on the system and establish persistence. This activity
13-
was observed in the wild as part of the Shai-Hulud worm.
10+
This rule detects the execution of Node.js pre or post-install scripts. These scripts are executed by the Node.js
11+
package manager (npm) during the installation of packages. Adversaries may abuse this technique to execute arbitrary
12+
commands on the system and establish persistence. This activity was observed in the wild as part of the Shai-Hulud worm.
1413
"""
1514
from = "now-9m"
1615
index = ["logs-endpoint.events.process*", "logs-crowdstrike.fdr*"]
1716
language = "eql"
1817
license = "Elastic License v2"
1918
name = "Node.js Pre or Post-Install Script Execution"
20-
references = ["https://www.elastic.co/blog/shai-hulud-worm-npm-supply-chain-compromise"]
19+
references = [
20+
"https://www.elastic.co/blog/shai-hulud-worm-npm-supply-chain-compromise",
21+
"https://www.wiz.io/blog/shai-hulud-2-0-ongoing-supply-chain-attack",
22+
]
2123
risk_score = 47
2224
rule_id = "0871a5d8-6b5f-4a12-a568-fd7bc05bd8db"
2325
setup = """## Setup
@@ -47,26 +49,28 @@ For more details on Elastic Defend refer to the [helper guide](https://www.elast
4749
"""
4850
severity = "medium"
4951
tags = [
50-
"Domain: Endpoint",
51-
"OS: Linux",
52-
"Use Case: Threat Detection",
53-
"Tactic: Persistence",
54-
"Tactic: Execution",
55-
"Tactic: Defense Evasion",
56-
"Data Source: Elastic Defend",
57-
"Resources: Investigation Guide",
58-
"Data Source: Crowdstrike",
52+
"Domain: Endpoint",
53+
"OS: Linux",
54+
"OS: macOS",
55+
"Use Case: Threat Detection",
56+
"Tactic: Persistence",
57+
"Tactic: Execution",
58+
"Tactic: Defense Evasion",
59+
"Data Source: Elastic Defend",
60+
"Resources: Investigation Guide",
61+
"Data Source: Crowdstrike",
5962
]
6063
type = "eql"
64+
6165
query = '''
6266
sequence by host.id with maxspan=10s
63-
[process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "ProcessRollup2") and process.name == "node" and process.args == "install"] by process.entity_id
64-
[process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "ProcessRollup2") and process.parent.name == "node"] by process.parent.entity_id
67+
[process where host.os.type in ("linux", "macos") and event.type == "start" and event.action in ("exec", "ProcessRollup2") and process.name == "node" and process.args == "install"] by process.entity_id
68+
[process where host.os.type in ("linux", "macos") and event.type == "start" and event.action in ("exec", "ProcessRollup2") and process.parent.name == "node"] by process.parent.entity_id
6569
'''
6670

71+
6772
[[rule.threat]]
6873
framework = "MITRE ATT&CK"
69-
7074
[[rule.threat.technique]]
7175
id = "T1543"
7276
name = "Create or Modify System Process"
@@ -77,33 +81,43 @@ id = "T1574"
7781
name = "Hijack Execution Flow"
7882
reference = "https://attack.mitre.org/techniques/T1574/"
7983

84+
8085
[rule.threat.tactic]
8186
id = "TA0003"
8287
name = "Persistence"
8388
reference = "https://attack.mitre.org/tactics/TA0003/"
84-
8589
[[rule.threat]]
8690
framework = "MITRE ATT&CK"
87-
8891
[[rule.threat.technique]]
8992
id = "T1059"
9093
name = "Command and Scripting Interpreter"
9194
reference = "https://attack.mitre.org/techniques/T1059/"
92-
9395
[[rule.threat.technique.subtechnique]]
9496
id = "T1059.004"
9597
name = "Unix Shell"
9698
reference = "https://attack.mitre.org/techniques/T1059/004/"
9799

100+
101+
[[rule.threat.technique]]
102+
id = "T1204"
103+
name = "User Execution"
104+
reference = "https://attack.mitre.org/techniques/T1204/"
105+
[[rule.threat.technique.subtechnique]]
106+
id = "T1204.005"
107+
name = "Malicious Library"
108+
reference = "https://attack.mitre.org/techniques/T1204/005/"
109+
110+
111+
98112
[rule.threat.tactic]
99113
id = "TA0002"
100114
name = "Execution"
101115
reference = "https://attack.mitre.org/tactics/TA0002/"
102-
103116
[[rule.threat]]
104117
framework = "MITRE ATT&CK"
105118

106119
[rule.threat.tactic]
107120
id = "TA0005"
108121
name = "Defense Evasion"
109122
reference = "https://attack.mitre.org/tactics/TA0005/"
123+

0 commit comments

Comments
 (0)