Command Line Obfuscation via Whitespace Padding
Identifies process execution events where the command line value contains a long sequence of whitespace characters or multiple occurrences of contiguous whitespace. Attackers may attempt to evade signature-based detections by padding their malicious command with unnecessary whitespace characters. These observations should be investigated for malicious behavior.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/06/30"
3integration = ["endpoint", "system", "windows", "auditd_manager", "m365_defender", "crowdstrike", "sentinel_one_cloud_funnel"]
4maturity = "production"
5updated_date = "2025/06/30"
6
7[rule]
8author = ["Elastic"]
9description = """
10Identifies process execution events where the command line value contains a long sequence of whitespace characters or
11multiple occurrences of contiguous whitespace. Attackers may attempt to evade signature-based detections by padding
12their malicious command with unnecessary whitespace characters. These observations should be investigated for malicious
13behavior.
14"""
15from = "now-9m"
16language = "esql"
17license = "Elastic License v2"
18name = "Command Line Obfuscation via Whitespace Padding"
19note = """## Triage and analysis
20
21### Investigating Command Line Obfuscation via Whitespace Padding
22
23This rule identifies process execution events where the command line value contains a long sequence of whitespace
24characters or multiple occurrences of contiguous whitespace. Attackers may attempt to evade signature-based detections
25by 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
31for 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
34modifications, 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
48evidence 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
63malware components.
64- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are
65identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business
66systems, 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
69mean time to respond (MTTR).
70"""
71risk_score = 47
72rule_id = "5a876e0d-d39a-49b9-8ad8-19c9b622203b"
73severity = "medium"
74tags = [
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]
84timestamp_override = "event.ingested"
85type = "esql"
86
87query = '''
88FROM 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]]
98framework = "MITRE ATT&CK"
99[[rule.threat.technique]]
100id = "T1027"
101name = "Obfuscated Files or Information"
102reference = "https://attack.mitre.org/techniques/T1027/"
103
104[[rule.threat.technique]]
105id = "T1140"
106name = "Deobfuscate/Decode Files or Information"
107reference = "https://attack.mitre.org/techniques/T1140/"
108
109
110[rule.threat.tactic]
111id = "TA0005"
112name = "Defense Evasion"
113reference = "https://attack.mitre.org/tactics/TA0005/"
114[[rule.threat]]
115framework = "MITRE ATT&CK"
116[[rule.threat.technique]]
117id = "T1059"
118name = "Command and Scripting Interpreter"
119reference = "https://attack.mitre.org/techniques/T1059/"
120[[rule.threat.technique.subtechnique]]
121id = "T1059.001"
122name = "PowerShell"
123reference = "https://attack.mitre.org/techniques/T1059/001/"
124
125
126
127[rule.threat.tactic]
128id = "TA0002"
129name = "Execution"
130reference = "https://attack.mitre.org/tactics/TA0002/"
Triage and analysis
Investigating Command Line Obfuscation via Whitespace Padding
This rule identifies process execution events where the command line value contains a long sequence of whitespace characters or multiple occurrences of contiguous whitespace. Attackers may attempt to evade signature-based detections by padding their malicious command with unnecessary whitespace characters.
Possible investigation steps
- Analyze the command line of the process in question for evidence of malicious code execution.
- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Investigate abnormal behaviors observed by the subject process such as network connections, registry or file modifications, and any spawned child processes.
- Retrieve the process executable and determine if it is malicious:
- Use a private sandboxed malware analysis system to perform analysis.
- Observe and collect information about the following activities:
- Attempts to contact external domains and addresses.
- File and registry access, modification, and creation activities.
- Service creation and launch activities.
- Scheduled tasks creation.
- Observe and collect information about the following activities:
- Use the PowerShell
Get-FileHash
cmdlet to get the files' SHA-256 hash values.- Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
- Use a private sandboxed malware analysis system to perform analysis.
False positive analysis
- Alerts derived from this rule are not inherently malicious. Analysts can dismiss the alert if they don't find enough evidence of further suspicious activity.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved host to prevent further post-compromise behavior.
- If the triage identified malware, search the environment for additional compromised hosts.
- Implement temporary network rules, procedures, and segmentation to contain the malware.
- Stop suspicious processes.
- Immediately block the identified indicators of compromise (IoCs).
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
- Remove the malicious certificate from the root certificate store.
- Remove and block malicious artifacts identified during triage.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
Related rules
- WebServer Access Logs Deleted
- AWS SSM `SendCommand` with Run Shell Command Parameters
- Elastic Agent Service Terminated
- Potential Hex Payload Execution via Command-Line
- File Creation in /var/log via Suspicious Process