Skip to content

Commit 9dfa21c

Browse files
Merge branch 'main' into prep-for-next-release-9.0
2 parents 48afe08 + 467034e commit 9dfa21c

File tree

3 files changed

+256
-2
lines changed

3 files changed

+256
-2
lines changed

rules_building_block/initial_access_cross_site_scripting.toml renamed to rules/_deprecated/initial_access_cross_site_scripting.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[metadata]
22
creation_date = "2023/07/12"
33
integration = ["apm"]
4-
maturity = "production"
5-
updated_date = "2024/09/01"
4+
maturity = "deprecated"
5+
updated_date = "2025/03/04"
6+
deprecation_date = "2025/03/04"
67

78
[rule]
89
author = ["Elastic"]
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
[metadata]
2+
creation_date = "2025/02/26"
3+
integration = ["endpoint"]
4+
maturity = "production"
5+
updated_date = "2025/02/26"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
This rule detects the creation of .pth files in system-wide and user-specific Python package
11+
directories, which can be abused for persistent code execution. .pth files automatically
12+
execute Python code when the interpreter starts, making them a stealthy persistence mechanism.
13+
Monitoring these paths helps identify unauthorized modifications that could indicate
14+
persistence by an attacker or malicious package injection.
15+
"""
16+
from = "now-9m"
17+
index = ["logs-endpoint.events.file*"]
18+
language = "eql"
19+
license = "Elastic License v2"
20+
name = "Python Path File (pth) Creation"
21+
references = [
22+
"https://dfir.ch/posts/publish_python_pth_extension/",
23+
"https://www.volexity.com/blog/2024/04/12/zero-day-exploitation-of-unauthenticated-remote-code-execution-vulnerability-in-globalprotect-cve-2024-3400/",
24+
]
25+
risk_score = 21
26+
rule_id = "7f65f984-5642-4291-a0a0-2bbefce4c617"
27+
setup = """## Setup
28+
29+
This rule requires data coming in from Elastic Defend.
30+
31+
### Elastic Defend Integration Setup
32+
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.
33+
34+
#### Prerequisite Requirements:
35+
- Fleet is required for Elastic Defend.
36+
- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
37+
38+
#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
39+
- Go to the Kibana home page and click "Add integrations".
40+
- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
41+
- Click "Add Elastic Defend".
42+
- Configure the integration name and optionally add a description.
43+
- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
44+
- 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).
45+
- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
46+
- 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.
47+
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).
48+
- Click "Save and Continue".
49+
- 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.
50+
For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
51+
"""
52+
severity = "low"
53+
tags = [
54+
"Domain: Endpoint",
55+
"OS: Linux",
56+
"Use Case: Threat Detection",
57+
"Tactic: Persistence",
58+
"Tactic: Execution",
59+
"Tactic: Defense Evasion",
60+
"Data Source: Elastic Defend"
61+
]
62+
timestamp_override = "event.ingested"
63+
type = "eql"
64+
query = '''
65+
file where host.os.type == "linux" and event.action in ("creation", "rename") and file.extension == "pth" and
66+
file.path like~ (
67+
"/usr/local/lib/python*/dist-packages/*",
68+
"/usr/lib/python*/dist-packages/*",
69+
"/usr/local/lib/python*/site-packages/*",
70+
"/usr/lib/python*/site-packages/*",
71+
"/home/*/.local/lib/python*/site-packages/*",
72+
"/opt/*/lib/python*/site-packages/*"
73+
) and process.executable != null and not (
74+
process.executable in (
75+
"/usr/local/bin/pip2", "/usr/bin/restic", "/usr/bin/pacman", "/usr/bin/dockerd", "/usr/local/bin/pip3",
76+
"/usr/bin/pip3", "/usr/local/bin/pip", "/usr/bin/pip", "/usr/bin/podman", "/usr/local/bin/poetry",
77+
"/usr/bin/poetry", "/usr/bin/pamac-daemon", "/opt/venv/bin/pip", "/usr/bin/dnf", "./venv/bin/pip",
78+
"/usr/bin/dnf5", "/bin/dnf5", "/bin/pip", "/bin/podman"
79+
) or
80+
process.executable like~ (
81+
"/usr/bin/python*", "/usr/local/bin/python*", "/opt/venv/bin/python*",
82+
"/nix/store/*libexec/docker/dockerd", "/snap/docker/*dockerd"
83+
)
84+
)
85+
'''
86+
87+
[[rule.threat]]
88+
framework = "MITRE ATT&CK"
89+
90+
[[rule.threat.technique]]
91+
id = "T1546"
92+
name = "Event Triggered Execution"
93+
reference = "https://attack.mitre.org/techniques/T1546/"
94+
95+
[[rule.threat.technique]]
96+
id = "T1574"
97+
name = "Hijack Execution Flow"
98+
reference = "https://attack.mitre.org/techniques/T1574/"
99+
100+
[rule.threat.tactic]
101+
id = "TA0003"
102+
name = "Persistence"
103+
reference = "https://attack.mitre.org/tactics/TA0003/"
104+
105+
[[rule.threat]]
106+
framework = "MITRE ATT&CK"
107+
108+
[[rule.threat.technique]]
109+
id = "T1059"
110+
name = "Command and Scripting Interpreter"
111+
reference = "https://attack.mitre.org/techniques/T1059/"
112+
113+
[[rule.threat.technique.subtechnique]]
114+
id = "T1059.004"
115+
name = "Unix Shell"
116+
reference = "https://attack.mitre.org/techniques/T1059/004/"
117+
118+
[rule.threat.tactic]
119+
id = "TA0002"
120+
name = "Execution"
121+
reference = "https://attack.mitre.org/tactics/TA0002/"
122+
123+
[[rule.threat]]
124+
framework = "MITRE ATT&CK"
125+
126+
[rule.threat.tactic]
127+
id = "TA0005"
128+
name = "Defense Evasion"
129+
reference = "https://attack.mitre.org/tactics/TA0005/"
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
[metadata]
2+
creation_date = "2025/02/26"
3+
integration = ["endpoint"]
4+
maturity = "production"
5+
updated_date = "2025/02/26"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
This rule detects the creation and modification of sitecustomize.py and usercustomize.py, which
11+
Python automatically executes on startup. Attackers can exploit these files for persistence by
12+
injecting malicious code. The rule monitors system-wide, user-specific, and virtual environment
13+
locations to catch unauthorized changes that could indicate persistence or backdooring attempts.
14+
"""
15+
from = "now-9m"
16+
index = ["logs-endpoint.events.file*"]
17+
language = "eql"
18+
license = "Elastic License v2"
19+
name = "Python Site or User Customize File Creation"
20+
risk_score = 21
21+
rule_id = "d788313c-9e0b-4c5a-8c4b-c3f05a47d5a8"
22+
setup = """## Setup
23+
24+
This rule requires data coming in from Elastic Defend.
25+
26+
### Elastic Defend Integration Setup
27+
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.
28+
29+
#### Prerequisite Requirements:
30+
- Fleet is required for Elastic Defend.
31+
- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
32+
33+
#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
34+
- Go to the Kibana home page and click "Add integrations".
35+
- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
36+
- Click "Add Elastic Defend".
37+
- Configure the integration name and optionally add a description.
38+
- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
39+
- 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).
40+
- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
41+
- 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.
42+
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).
43+
- Click "Save and Continue".
44+
- 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.
45+
For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
46+
"""
47+
severity = "low"
48+
tags = [
49+
"Domain: Endpoint",
50+
"OS: Linux",
51+
"Use Case: Threat Detection",
52+
"Tactic: Persistence",
53+
"Tactic: Execution",
54+
"Tactic: Defense Evasion",
55+
"Data Source: Elastic Defend"
56+
]
57+
timestamp_override = "event.ingested"
58+
type = "eql"
59+
query = '''
60+
file where host.os.type == "linux" and event.type in ("creation", "rename") and process.executable != null and
61+
file.path like~ (
62+
"/usr/lib/python*/sitecustomize.py",
63+
"/usr/local/lib/python*/sitecustomize.py",
64+
"/usr/lib/python*/dist-packages/sitecustomize.py",
65+
"/usr/local/lib/python*/dist-packages/sitecustomize.py",
66+
"/opt/*/lib/python*/sitecustomize.py",
67+
"/home/*/.local/lib/python*/site-packages/usercustomize.py",
68+
"/home/*/.config/python/usercustomize.py"
69+
) and not (
70+
process.executable in (
71+
"/usr/local/bin/pip2", "/usr/bin/restic", "/usr/bin/pacman", "/usr/bin/dockerd", "/usr/local/bin/pip3",
72+
"/usr/bin/pip3", "/usr/local/bin/pip", "/usr/bin/pip", "/usr/bin/podman", "/usr/local/bin/poetry",
73+
"/usr/bin/poetry", "/usr/bin/pamac-daemon", "./venv/bin/pip"
74+
) or
75+
process.executable like~ (
76+
"/usr/bin/python*", "/usr/local/bin/python*", "/opt/venv/bin/python*",
77+
"/nix/store/*libexec/docker/dockerd", "/snap/docker/*dockerd"
78+
)
79+
)
80+
'''
81+
82+
[[rule.threat]]
83+
framework = "MITRE ATT&CK"
84+
85+
[[rule.threat.technique]]
86+
id = "T1546"
87+
name = "Event Triggered Execution"
88+
reference = "https://attack.mitre.org/techniques/T1546/"
89+
90+
[[rule.threat.technique]]
91+
id = "T1574"
92+
name = "Hijack Execution Flow"
93+
reference = "https://attack.mitre.org/techniques/T1574/"
94+
95+
[rule.threat.tactic]
96+
id = "TA0003"
97+
name = "Persistence"
98+
reference = "https://attack.mitre.org/tactics/TA0003/"
99+
100+
[[rule.threat]]
101+
framework = "MITRE ATT&CK"
102+
103+
[[rule.threat.technique]]
104+
id = "T1059"
105+
name = "Command and Scripting Interpreter"
106+
reference = "https://attack.mitre.org/techniques/T1059/"
107+
108+
[[rule.threat.technique.subtechnique]]
109+
id = "T1059.004"
110+
name = "Unix Shell"
111+
reference = "https://attack.mitre.org/techniques/T1059/004/"
112+
113+
[rule.threat.tactic]
114+
id = "TA0002"
115+
name = "Execution"
116+
reference = "https://attack.mitre.org/tactics/TA0002/"
117+
118+
[[rule.threat]]
119+
framework = "MITRE ATT&CK"
120+
121+
[rule.threat.tactic]
122+
id = "TA0005"
123+
name = "Defense Evasion"
124+
reference = "https://attack.mitre.org/tactics/TA0005/"

0 commit comments

Comments
 (0)