Skip to content

Commit 7bd4787

Browse files
Merge branch 'main' into 4977-bug-rule-toml-write-formatting-wrongly-formats-x
2 parents 2ced0dc + 58f62fd commit 7bd4787

16 files changed

+435
-87
lines changed
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
[metadata]
2+
creation_date = "2025/06/30"
3+
integration = ["endpoint", "system", "windows", "auditd_manager", "m365_defender", "crowdstrike", "sentinel_one_cloud_funnel"]
4+
maturity = "production"
5+
updated_date = "2025/06/30"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
Identifies process execution events where the command line value contains a long sequence of whitespace characters or
11+
multiple occurrences of contiguous whitespace. Attackers may attempt to evade signature-based detections by padding
12+
their malicious command with unnecessary whitespace characters. These observations should be investigated for malicious
13+
behavior.
14+
"""
15+
from = "now-9m"
16+
language = "esql"
17+
license = "Elastic License v2"
18+
name = "Command Line Obfuscation via Whitespace Padding"
19+
note = """## Triage and analysis
20+
21+
### Investigating Command Line Obfuscation via Whitespace Padding
22+
23+
This rule identifies process execution events where the command line value contains a long sequence of whitespace
24+
characters or multiple occurrences of contiguous whitespace. Attackers may attempt to evade signature-based detections
25+
by padding their malicious command with unnecessary whitespace characters.
26+
27+
#### Possible investigation steps
28+
29+
- Analyze the command line of the process in question for evidence of malicious code execution.
30+
- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files
31+
for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
32+
- Investigate other alerts associated with the user/host during the past 48 hours.
33+
- Investigate abnormal behaviors observed by the subject process such as network connections, registry or file
34+
modifications, and any spawned child processes.
35+
- Retrieve the process executable and determine if it is malicious:
36+
- Use a private sandboxed malware analysis system to perform analysis.
37+
- Observe and collect information about the following activities:
38+
- Attempts to contact external domains and addresses.
39+
- File and registry access, modification, and creation activities.
40+
- Service creation and launch activities.
41+
- Scheduled tasks creation.
42+
- Use the PowerShell `Get-FileHash` cmdlet to get the files' SHA-256 hash values.
43+
- Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
44+
45+
### False positive analysis
46+
47+
- Alerts derived from this rule are not inherently malicious. Analysts can dismiss the alert if they don't find enough
48+
evidence of further suspicious activity.
49+
50+
### Response and remediation
51+
52+
- Initiate the incident response process based on the outcome of the triage.
53+
- Isolate the involved host to prevent further post-compromise behavior.
54+
- If the triage identified malware, search the environment for additional compromised hosts.
55+
- Implement temporary network rules, procedures, and segmentation to contain the malware.
56+
- Stop suspicious processes.
57+
- Immediately block the identified indicators of compromise (IoCs).
58+
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that
59+
attackers could use to reinfect the system.
60+
- Remove the malicious certificate from the root certificate store.
61+
- Remove and block malicious artifacts identified during triage.
62+
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and
63+
malware components.
64+
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are
65+
identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business
66+
systems, and web services.
67+
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
68+
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the
69+
mean time to respond (MTTR).
70+
"""
71+
risk_score = 47
72+
rule_id = "5a876e0d-d39a-49b9-8ad8-19c9b622203b"
73+
severity = "medium"
74+
tags = [
75+
"Domain: Endpoint",
76+
"OS: Windows",
77+
"OS: macOS",
78+
"OS: Linux",
79+
"Use Case: Threat Detection",
80+
"Tactic: Defense Evasion",
81+
"Tactic: Execution",
82+
"Resources: Investigation Guide"
83+
]
84+
timestamp_override = "event.ingested"
85+
type = "esql"
86+
87+
query = '''
88+
FROM logs-* metadata _id, _version, _index
89+
| where event.category == "process" and event.type == "start" and event.action != "fork"
90+
// more than 100 spaces in process.command_line
91+
| eval multi_spaces = LOCATE(process.command_line, space(100))
92+
| where multi_spaces > 0
93+
| keep user.name, host.id, host.name, process.command_line, process.executable, process.parent.executable
94+
'''
95+
96+
97+
[[rule.threat]]
98+
framework = "MITRE ATT&CK"
99+
[[rule.threat.technique]]
100+
id = "T1027"
101+
name = "Obfuscated Files or Information"
102+
reference = "https://attack.mitre.org/techniques/T1027/"
103+
104+
[[rule.threat.technique]]
105+
id = "T1140"
106+
name = "Deobfuscate/Decode Files or Information"
107+
reference = "https://attack.mitre.org/techniques/T1140/"
108+
109+
110+
[rule.threat.tactic]
111+
id = "TA0005"
112+
name = "Defense Evasion"
113+
reference = "https://attack.mitre.org/tactics/TA0005/"
114+
[[rule.threat]]
115+
framework = "MITRE ATT&CK"
116+
[[rule.threat.technique]]
117+
id = "T1059"
118+
name = "Command and Scripting Interpreter"
119+
reference = "https://attack.mitre.org/techniques/T1059/"
120+
[[rule.threat.technique.subtechnique]]
121+
id = "T1059.001"
122+
name = "PowerShell"
123+
reference = "https://attack.mitre.org/techniques/T1059/001/"
124+
125+
126+
127+
[rule.threat.tactic]
128+
id = "TA0002"
129+
name = "Execution"
130+
reference = "https://attack.mitre.org/tactics/TA0002/"

rules/integrations/azure/initial_access_entra_graph_single_session_from_multiple_addresses.toml

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
creation_date = "2025/05/08"
33
integration = ["azure"]
44
maturity = "production"
5-
updated_date = "2025/07/16"
5+
updated_date = "2025/07/31"
6+
67

78
[rule]
89
author = ["Elastic"]
910
description = """
1011
Identifies potential session hijacking or token replay in Microsoft Entra ID. This rule detects cases where a user signs
11-
in and subsequently accesses Microsoft Graph from a different IP address using the same session ID within a short time
12-
window. This may indicate the use of a stolen refresh/access token or session cookie to impersonate the user and
13-
interact with Microsoft services.
12+
in and subsequently accesses Microsoft Graph from a different IP address using the same session ID. This may indicate a
13+
successful OAuth phishing attack, session hijacking, or token replay attack, where an adversary has stolen a session
14+
cookie or refresh/access token and is impersonating the user from an alternate host or location.
1415
"""
1516
false_positives = [
1617
"""
@@ -20,40 +21,39 @@ false_positives = [
2021
are involved.
2122
""",
2223
]
23-
from = "now-1h"
24+
from = "now-31m"
25+
interval = "30m"
2426
language = "esql"
2527
license = "Elastic License v2"
26-
name = "Microsoft Entra ID Session Reuse with Suspicious Graph Access"
28+
name = "Microsoft Entra ID Suspicious Session Reuse to Graph Access"
2729
note = """## Triage and analysis
2830
29-
### Investigating Microsoft Entra ID Session Reuse with Suspicious Graph Access
31+
### Investigating Microsoft Entra ID Suspicious Session Reuse to Graph Access
3032
31-
This rule identifies when Microsoft Graph is accessed from a different IP than the one used for the original sign-in,
32-
but using the same session ID within 5 minutes. This may suggest an adversary has stolen a session cookie or refresh/access
33-
token and is impersonating the user from an alternate host or location.
33+
Identifies potential session hijacking or token replay in Microsoft Entra ID. This rule detects cases where a user signs in and subsequently accesses Microsoft Graph from a different IP address using the same session ID. This may indicate a successful OAuth phishing attack, session hijacking, or token replay attack, where an adversary has stolen a session cookie or refresh/access token and is impersonating the user from an alternate host or location.
3434
3535
This rule uses ESQL aggregations and thus has dynamically generated fields. Correlation of the values in the alert document may need to be
3636
performed to the original sign-in and Graph events for further context.
3737
3838
### Investigation Steps
3939
40-
- Review the `user_id`, `session_id`, and `source_ip_list`. Confirm whether both IPs belong to the same user and geography.
41-
- Check for inconsistencies in `client_id_list` (e.g., unknown apps) or user agents across correlated events.
42-
- Investigate recent phishing reports or device infections for the `user_id`.
43-
- Pivot to Entra ID `auditlogs` to see if a device was registered or privileges were modified.
44-
- Review `graph_time` to determine what action was taken after the sign-in.
45-
- Use the `session_id` to correlate with other logs in the same time window to identify any additional suspicious activity.
40+
- This rule relies on an aggregation-based ESQL query, therefore the alert document will contain dynamically generated fields.
41+
- To pivot into the original events, it is recommended to use the values captured to filter in timeline or discovery for the original sign-in and Graph events.
42+
- Review the session ID and user ID to identify the user account involved in the suspicious activity.
43+
- Check the source addresses involved in the sign-in and Graph access to determine if they are known or expected locations for the user.
44+
- The sign-in source addresses should be two, one for the initial phishing sign-in and the other when exchanging the auth code for a token by the adversary.
45+
- The Graph API source address should identify the IP address used by the adversary to access Microsoft Graph.
46+
- Review the user agent strings for the sign-in and Graph access events to identify any anomalies or indicators of compromise.
47+
- Check the timestamp difference between the sign-in and Graph access events to determine if they occurred within a reasonable time frame that would suggest successful phishing to token issuance and then Graph access.
48+
- Identify the original sign-in event to investigation if conditional access policies were applied, such as requiring multi-factor authentication or blocking access from risky locations. In phishing scenarios, these policies likely were applied as the victim user would have been prompted to authenticate.
4649
4750
### False Positive Analysis
48-
- This pattern may occur if the user is switching between networks (e.g., corporate to mobile) or using a VPN.
49-
- Developers or power users leveraging multiple environments may also trigger this detection if session persistence spans IP ranges.
50-
- However, this behavior is rare and warrants investigation when rapid IP switching and Graph access are involved.
51-
- If the user is a developer or automation engineer, validate if this behavior was for testing purposes.
52-
- If the user is a system administrator, validate if this behavior was for administrative purposes.
51+
- This pattern may occur during legitimate device switching or roaming between networks (e.g., corporate to mobile).
52+
- Developers or power users leveraging multiple environments may also trigger this detection if session persistence spans IP ranges. Still, this behavior is rare and warrants investigation when rapid IP switching and Graph access are involved.
5353
5454
### Response Recommendations
5555
56-
- If confirmed malicious, revoke all refresh/access tokens for the `user_id`.
56+
- If confirmed malicious, revoke all refresh/access tokens for the user principal.
5757
- Block the source IP(s) involved in the Graph access.
5858
- Notify the user and reset credentials.
5959
- Review session control policies and conditional access enforcement.
@@ -65,14 +65,16 @@ references = [
6565
"https://github.com/dirkjanm/ROADtools",
6666
"https://attack.mitre.org/techniques/T1078/004/",
6767
]
68-
risk_score = 73
68+
risk_score = 47
6969
rule_id = "0d3d2254-2b4a-11f0-a019-f661ea17fbcc"
7070
setup = """#### Required Microsoft Entra ID Sign-In and Graph Activity Logs
7171
This rule requires the Microsoft Entra ID Sign-In Logs and Microsoft Graph Activity Logs integration to be enabled and configured to collect audit and activity logs via Azure Event Hub.
7272
"""
73-
severity = "high"
73+
severity = "medium"
7474
tags = [
7575
"Domain: Cloud",
76+
"Domain: Identity",
77+
"Domain: API",
7678
"Data Source: Azure",
7779
"Data Source: Microsoft Entra ID",
7880
"Data Source: Microsoft Entra ID Sign-In Logs",
@@ -88,7 +90,7 @@ timestamp_override = "event.ingested"
8890
type = "esql"
8991

9092
query = '''
91-
from logs-azure.*
93+
from logs-azure.signinlogs-*, logs-azure.graphactivitylogs-* metadata _id, _version, _index
9294
| where
9395
(event.dataset == "azure.signinlogs"
9496
and source.`as`.organization.name != "MICROSOFT-CORP-MSN-as-BLOCK"

rules/integrations/okta/persistence_mfa_deactivation_with_no_reactivation.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2020/05/20"
33
integration = ["okta"]
44
maturity = "production"
5-
updated_date = "2025/07/02"
5+
updated_date = "2025/08/15"
66

77
[rule]
88
author = ["Elastic"]
@@ -33,11 +33,12 @@ This rule fires when an Okta user account has MFA deactivated and no subsequent
3333
3434
#### Possible investigation steps:
3535
36-
- Identify the actor related to the alert by reviewing `okta.actor.alternate_id` field in the alert. This should give the username of the account being targeted.
37-
- Review `okta.target` or `user.target.full_name` fields to determine if deactivation was performed by a se parate user.
38-
- Using the `okta.actor.alternate_id` field, search for MFA re-activation events where `okta.event_type` is `user.mfa.factor.activate`.
39-
- Review events where `okta.event_type` is `user.authenticate*` to determine if the user account had suspicious login activity.
36+
- Identify the entity related to the alert by reviewing `okta.target.alternate_id`, `okta.target.id` or `user.target.full_name` fields. This should give the username of the account being targeted. Verify if MFA is deactivated for the target entity.
37+
- Using the `okta.target.alternate_id` field, search for MFA re-activation events where `okta.event_type` is `user.mfa.factor.activate`. Note if MFA re-activation attempts were made against the target.
38+
- Identify the actor performing the deactivation by reviewing `okta.actor.alternate_id`, `okta.actor.id` or `user.full_name` fields. This should give the username of the account performing the action. Determine if deactivation was performed by a separate user.
39+
- Review events where `okta.event_type` is `user.authenticate*` to determine if the actor or target accounts had suspicious login activity.
4040
- Geolocation details found in `client.geo*` related fields may be useful in determining if the login activity was suspicious for this user.
41+
- Examine related administrative activity by the actor for privilege misuse or suspicious changes.
4142
4243
#### False positive steps:
4344
@@ -75,7 +76,7 @@ tags = [
7576
type = "eql"
7677

7778
query = '''
78-
sequence by okta.actor.id with maxspan=12h
79+
sequence by okta.target.id with maxspan=12h
7980
[any where event.dataset == "okta.system" and okta.event_type in ("user.mfa.factor.deactivate", "user.mfa.factor.reset_all")
8081
and okta.outcome.reason != "User reset SECURITY_QUESTION factor" and okta.outcome.result == "SUCCESS"]
8182
![any where event.dataset == "okta.system" and okta.event_type == "user.mfa.factor.activate"]

rules/windows/defense_evasion_disable_posh_scriptblocklogging.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2022/01/31"
33
integration = ["endpoint", "windows", "m365_defender", "sentinel_one_cloud_funnel"]
44
maturity = "production"
5-
updated_date = "2025/03/20"
5+
updated_date = "2025/08/13"
66

77
[rule]
88
author = ["Elastic"]
@@ -89,7 +89,15 @@ registry where host.os.type == "windows" and event.type == "change" and
8989
"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging\\EnableScriptBlockLogging",
9090
"\\REGISTRY\\MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging\\EnableScriptBlockLogging",
9191
"MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging\\EnableScriptBlockLogging"
92-
) and registry.data.strings : ("0", "0x00000000")
92+
) and registry.data.strings : ("0", "0x00000000") and
93+
not (
94+
process.executable : (
95+
"?:\\Windows\\System32\\svchost.exe",
96+
"?:\\Windows\\System32\\DeviceEnroller.exe",
97+
"?:\\Windows\\system32\\omadmclient.exe",
98+
"?:\\Program Files (x86)\\N-able Technologies\\AutomationManagerAgent\\AutomationManager.AgentService.exe"
99+
) and user.id == "S-1-5-18"
100+
)
93101
'''
94102

95103

rules/windows/defense_evasion_posh_obfuscation_backtick.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2025/04/15"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/07/16"
5+
updated_date = "2025/08/14"
66

77
[rule]
88
author = ["Elastic"]
@@ -107,6 +107,7 @@ from logs-windows.powershell_operational* metadata _id, _version, _index
107107
powershell.file.script_block_text,
108108
powershell.file.script_block_id,
109109
file.name,
110+
file.directory,
110111
file.path,
111112
powershell.sequence,
112113
powershell.total,
@@ -119,11 +120,16 @@ from logs-windows.powershell_operational* metadata _id, _version, _index
119120
// Filter for scripts that match the pattern at least 10 times
120121
| where Esql.script_block_pattern_count >= 10
121122
122-
// Filter FPs, and due to the behavior of the like operator, allow null values
123-
| where (file.name not like "TSS_*.psm1" or file.name is null)
123+
| where file.name not like "TSS_*.psm1"
124+
// ESQL requires this condition, otherwise it only returns matches where file.name exists.
125+
or file.name is null
124126
125127
// VSCode Shell integration
126128
| where not powershell.file.script_block_text like "*$([char]0x1b)]633*"
129+
130+
| where not file.directory == "C:\\Program Files\\MVPSI\\JAMS\\Agent\\Temp"
131+
// ESQL requires this condition, otherwise it only returns matches where file.directory exists.
132+
or file.directory is null
127133
'''
128134

129135

rules/windows/defense_evasion_posh_obfuscation_high_number_proportion.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2025/04/16"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/07/16"
5+
updated_date = "2025/08/14"
66

77
[rule]
88
author = ["Elastic"]
@@ -108,6 +108,7 @@ from logs-windows.powershell_operational* metadata _id, _version, _index
108108
Esql.script_block_tmp,
109109
powershell.file.script_block_text,
110110
powershell.file.script_block_id,
111+
file.directory,
111112
file.path,
112113
powershell.sequence,
113114
powershell.total,
@@ -120,8 +121,15 @@ from logs-windows.powershell_operational* metadata _id, _version, _index
120121
// Filter for scripts with high numeric character ratio
121122
| where Esql.script_block_ratio > 0.30
122123
123-
// Exclude noisy patterns such as 64-character hash lists
124-
| where not powershell.file.script_block_text rlike """.*\"[a-fA-F0-9]{64}\"\,.*"""
124+
// Exclude Windows Defender Noisy Patterns
125+
| where not (
126+
file.directory == "C:\\ProgramData\\Microsoft\\Windows Defender Advanced Threat Protection\\Downloads" or
127+
file.directory like "C:\\\\ProgramData\\\\Microsoft\\\\Windows Defender Advanced Threat Protection\\\\DataCollection*"
128+
)
129+
// ESQL requires this condition, otherwise it only returns matches where file.directory exists.
130+
or file.directory is null
131+
| where not powershell.file.script_block_text like "*[System.IO.File]::Open('C:\\\\ProgramData\\\\Microsoft\\\\Windows Defender Advanced Threat Protection\\\\DataCollection*"
132+
| where not powershell.file.script_block_text : "26a24ae4-039d-4ca4-87b4-2f64180311f0"
125133
'''
126134

127135

rules/windows/defense_evasion_posh_obfuscation_iex_env_vars_reconstruction.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2025/04/16"
33
integration = ["windows"]
44
maturity = "production"
5-
updated_date = "2025/07/16"
5+
updated_date = "2025/08/14"
66

77
[rule]
88
author = ["Elastic"]
@@ -50,7 +50,7 @@ PowerShell's Invoke-Expression (IEX) command is a powerful tool for executing st
5050
- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if additional systems are affected.
5151
- Implement additional monitoring for unusual PowerShell activity and environment variable manipulations to enhance detection of similar threats in the future.
5252
"""
53-
risk_score = 21
53+
risk_score = 47
5454
rule_id = "b0c98cfb-0745-4513-b6f9-08dddb033490"
5555
setup = """## Setup
5656
@@ -70,7 +70,7 @@ Steps to implement the logging policy via registry:
7070
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
7171
```
7272
"""
73-
severity = "low"
73+
severity = "medium"
7474
tags = [
7575
"Domain: Endpoint",
7676
"OS: Windows",

0 commit comments

Comments
 (0)