Suspicious CertUtil Commands
Identifies suspicious commands being used with certutil.exe. CertUtil is a native Windows component which is part of Certificate Services. CertUtil is often abused by attackers to live off the land for stealthier command and control or data exfiltration.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2020/02/18"
3integration = ["endpoint", "windows", "system", "m365_defender", "sentinel_one_cloud_funnel", "crowdstrike"]
4maturity = "production"
5updated_date = "2024/11/02"
6min_stack_version = "8.14.0"
7min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
8
9[transform]
10[[transform.osquery]]
11label = "Osquery - Retrieve DNS Cache"
12query = "SELECT * FROM dns_cache"
13
14[[transform.osquery]]
15label = "Osquery - Retrieve All Services"
16query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
17
18[[transform.osquery]]
19label = "Osquery - Retrieve Services Running on User Accounts"
20query = """
21SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
22NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
23user_account == null)
24"""
25
26[[transform.osquery]]
27label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
28query = """
29SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
30services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
31authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
32"""
33
34
35[rule]
36author = ["Elastic", "Austin Songer"]
37description = """
38Identifies suspicious commands being used with certutil.exe. CertUtil is a native Windows component which is part of
39Certificate Services. CertUtil is often abused by attackers to live off the land for stealthier command and control or
40data exfiltration.
41"""
42from = "now-9m"
43index = [
44 "winlogbeat-*",
45 "logs-endpoint.events.process-*",
46 "logs-windows.forwarded*",
47 "logs-windows.sysmon_operational-*",
48 "endgame-*",
49 "logs-system.security*",
50 "logs-m365_defender.event-*",
51 "logs-sentinel_one_cloud_funnel.*",
52 "logs-crowdstrike.fdr*",
53]
54language = "eql"
55license = "Elastic License v2"
56name = "Suspicious CertUtil Commands"
57note = """## Triage and analysis
58
59### Investigating Suspicious CertUtil Commands
60
61`certutil.exe` is a command line utility program that is included with Microsoft Windows operating systems. It is used to manage and manipulate digital certificates and certificate services on computers running Windows.
62
63Attackers can abuse `certutil.exe` utility to download and/or deobfuscate malware, offensive security tools, and certificates from external sources to take the next steps in a compromised environment. This rule identifies command line arguments used to accomplish these behaviors.
64
65> **Note**:
66> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/master/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
67
68#### Possible investigation steps
69
70- Investigate the script 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.
71- Investigate other alerts associated with the user/host during the past 48 hours.
72- Examine the command line to determine the nature of the execution.
73 - If files were downloaded, retrieve them and check whether they were run, and under which security context.
74 - If files were obfuscated or deobfuscated, retrieve them.
75- Examine the host for derived artifacts that indicate suspicious activities:
76 - Analyze the involved files using a private sandboxed analysis system.
77 - Observe and collect information about the following activities in both the sandbox and the alert subject host:
78 - Attempts to contact external domains and addresses.
79 - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' `process.entity_id`.
80 - Examine the DNS cache for suspicious or anomalous entries.
81 - $osquery_0
82 - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
83 - Examine the host services for suspicious or anomalous entries.
84 - $osquery_1
85 - $osquery_2
86 - $osquery_3
87 - Retrieve the files' SHA-256 hash values using the PowerShell `Get-FileHash` cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
88
89### False positive analysis
90
91- If this rule is noisy in your environment due to expected activity, consider adding exceptions — preferably with a combination of user and command line conditions.
92
93### Response and remediation
94
95- Initiate the incident response process based on the outcome of the triage.
96- Isolate the involved host to prevent further post-compromise behavior.
97- If the triage identified malware, search the environment for additional compromised hosts.
98 - Implement temporary network rules, procedures, and segmentation to contain the malware.
99 - Stop suspicious processes.
100 - Immediately block the identified indicators of compromise (IoCs).
101 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
102- Remove and block malicious artifacts identified during triage.
103- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
104- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
105- 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).
106"""
107references = [
108 "https://twitter.com/Moriarty_Meng/status/984380793383370752",
109 "https://twitter.com/egre55/status/1087685529016193025",
110 "https://www.sysadmins.lv/blog-en/certutil-tips-and-tricks-working-with-x509-file-format.aspx",
111 "https://docs.microsoft.com/en-us/archive/blogs/pki/basic-crl-checking-with-certutil",
112 "https://www.elastic.co/security-labs/siestagraph-new-implant-uncovered-in-asean-member-foreign-ministry",
113]
114risk_score = 47
115rule_id = "fd70c98a-c410-42dc-a2e3-761c71848acf"
116severity = "medium"
117tags = [
118 "Domain: Endpoint",
119 "OS: Windows",
120 "Use Case: Threat Detection",
121 "Tactic: Defense Evasion",
122 "Data Source: Elastic Endgame",
123 "Resources: Investigation Guide",
124 "Data Source: Elastic Defend",
125 "Data Source: System",
126 "Data Source: Microsoft Defender for Endpoint",
127 "Data Source: Sysmon",
128 "Data Source: SentinelOne",
129 "Data Source: Crowdstrike",
130]
131timeline_id = "e70679c2-6cde-4510-9764-4823df18f7db"
132timeline_title = "Comprehensive Process Timeline"
133timestamp_override = "event.ingested"
134type = "eql"
135
136query = '''
137process where host.os.type == "windows" and event.type == "start" and
138 (process.name : "certutil.exe" or ?process.pe.original_file_name == "CertUtil.exe") and
139 process.args : ("?decode", "?encode", "?urlcache", "?verifyctl", "?encodehex", "?decodehex", "?exportPFX")
140'''
141
142
143[[rule.threat]]
144framework = "MITRE ATT&CK"
145[[rule.threat.technique]]
146id = "T1140"
147name = "Deobfuscate/Decode Files or Information"
148reference = "https://attack.mitre.org/techniques/T1140/"
149
150
151[rule.threat.tactic]
152id = "TA0005"
153name = "Defense Evasion"
154reference = "https://attack.mitre.org/tactics/TA0005/"
Triage and analysis
Investigating Suspicious CertUtil Commands
certutil.exe
is a command line utility program that is included with Microsoft Windows operating systems. It is used to manage and manipulate digital certificates and certificate services on computers running Windows.
Attackers can abuse certutil.exe
utility to download and/or deobfuscate malware, offensive security tools, and certificates from external sources to take the next steps in a compromised environment. This rule identifies command line arguments used to accomplish these behaviors.
Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
Possible investigation steps
- Investigate the script 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.
- Examine the command line to determine the nature of the execution.
- If files were downloaded, retrieve them and check whether they were run, and under which security context.
- If files were obfuscated or deobfuscated, retrieve them.
- Examine the host for derived artifacts that indicate suspicious activities:
- Analyze the involved files using a private sandboxed analysis system.
- Observe and collect information about the following activities in both the sandbox and the alert subject host:
- Attempts to contact external domains and addresses.
- Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process'
process.entity_id
. - Examine the DNS cache for suspicious or anomalous entries.
- $osquery_0
- Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process'
- Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
- Examine the host services for suspicious or anomalous entries.
- $osquery_1
- $osquery_2
- $osquery_3
- Attempts to contact external domains and addresses.
- Retrieve the files' SHA-256 hash values using the PowerShell
Get-FileHash
cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
False positive analysis
- If this rule is noisy in your environment due to expected activity, consider adding exceptions — preferably with a combination of user and command line conditions.
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 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.
- 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).
References
Related rules
- IIS HTTP Logging Disabled
- Remote Desktop Enabled in Windows Firewall by Netsh
- Windows Firewall Disabled via PowerShell
- Adding Hidden File Attribute via Attrib
- Clearing Windows Console History