Potential File Transfer via Certreq
Identifies Certreq making an HTTP Post request. Adversaries could abuse Certreq to download files or upload data to a remote URL.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/01/13"
3integration = ["endpoint", "windows", "system", "m365_defender", "sentinel_one_cloud_funnel", "crowdstrike"]
4maturity = "production"
5updated_date = "2025/03/20"
6
7[transform]
8[[transform.osquery]]
9label = "Osquery - Retrieve DNS Cache"
10query = "SELECT * FROM dns_cache"
11
12[[transform.osquery]]
13label = "Osquery - Retrieve All Services"
14query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
15
16[[transform.osquery]]
17label = "Osquery - Retrieve Services Running on User Accounts"
18query = """
19SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
20NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
21user_account == null)
22"""
23
24[[transform.osquery]]
25label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
26query = """
27SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
28services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
29authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
30"""
31
32
33[rule]
34author = ["Elastic"]
35description = """
36Identifies Certreq making an HTTP Post request. Adversaries could abuse Certreq to download files or upload data to a
37remote URL.
38"""
39from = "now-9m"
40index = [
41 "endgame-*",
42 "logs-crowdstrike.fdr*",
43 "logs-endpoint.events.process-*",
44 "logs-m365_defender.event-*",
45 "logs-sentinel_one_cloud_funnel.*",
46 "logs-system.security*",
47 "logs-windows.forwarded*",
48 "logs-windows.sysmon_operational-*",
49 "winlogbeat-*",
50]
51language = "eql"
52license = "Elastic License v2"
53name = "Potential File Transfer via Certreq"
54note = """## Triage and analysis
55
56### Investigating Potential File Transfer via Certreq
57
58Certreq is a command-line utility in Windows operating systems that allows users to request and manage certificates from certificate authorities. It is primarily used for generating certificate signing requests (CSRs) and installing certificates. However, adversaries may abuse Certreq's functionality to download files or upload data to a remote URL by making an HTTP POST request.
59
60This rule identifies the potential abuse of Certreq to download files or upload data to a remote URL.
61
62> **Note**:
63> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/current/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
64
65#### Possible investigation steps
66
67- 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.
68- Identify the user account that performed the action and whether it should perform this kind of action.
69- Contact the account owner and confirm whether they are aware of this activity.
70- Investigate other alerts associated with the user/host during the past 48 hours.
71- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
72- Examine the details of the dropped file, and whether it was executed.
73- Check the reputation of the domain or IP address used to host the downloaded file or if the user downloaded the file from an internal system.
74- Examine the host for derived artifacts that indicate suspicious activities:
75 - Analyze the file using a private sandboxed analysis system.
76 - Observe and collect information about the following activities in both the sandbox and the alert subject host:
77 - Attempts to contact external domains and addresses.
78 - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process's `process.entity_id`.
79 - Examine the DNS cache for suspicious or anomalous entries.
80 - $osquery_0
81 - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
82 - Examine the host services for suspicious or anomalous entries.
83 - $osquery_1
84 - $osquery_2
85 - $osquery_3
86 - 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.
87
88### False positive analysis
89
90- This activity is unusual but can be done by administrators. Benign true positives (B-TPs) can be added as exceptions if necessary.
91
92### Response and remediation
93
94- Initiate the incident response process based on the outcome of the triage.
95- Isolate the involved host to prevent further post-compromise behavior.
96- If the triage identified malware, search the environment for additional compromised hosts.
97 - Implement temporary network rules, procedures, and segmentation to contain the malware.
98 - Stop suspicious processes.
99 - Immediately block the identified indicators of compromise (IoCs).
100 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
101- Remove and block malicious artifacts identified during triage.
102- 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.
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 = ["https://lolbas-project.github.io/lolbas/Binaries/Certreq/"]
108risk_score = 47
109rule_id = "79f0a1f7-ed6b-471c-8eb1-23abd6470b1c"
110severity = "medium"
111tags = [
112 "Domain: Endpoint",
113 "OS: Windows",
114 "Use Case: Threat Detection",
115 "Tactic: Defense Evasion",
116 "Tactic: Command and Control",
117 "Tactic: Exfiltration",
118 "Data Source: Elastic Endgame",
119 "Data Source: Elastic Defend",
120 "Data Source: Windows Security Event Logs",
121 "Data Source: Microsoft Defender for Endpoint",
122 "Data Source: Sysmon",
123 "Data Source: SentinelOne",
124 "Data Source: Crowdstrike",
125 "Resources: Investigation Guide",
126]
127timestamp_override = "event.ingested"
128type = "eql"
129
130query = '''
131process where host.os.type == "windows" and event.type == "start" and
132 (process.name : "CertReq.exe" or ?process.pe.original_file_name == "CertReq.exe") and process.args : "-Post"
133'''
134
135
136[[rule.threat]]
137framework = "MITRE ATT&CK"
138[[rule.threat.technique]]
139id = "T1105"
140name = "Ingress Tool Transfer"
141reference = "https://attack.mitre.org/techniques/T1105/"
142
143
144[rule.threat.tactic]
145id = "TA0011"
146name = "Command and Control"
147reference = "https://attack.mitre.org/tactics/TA0011/"
148[[rule.threat]]
149framework = "MITRE ATT&CK"
150[[rule.threat.technique]]
151id = "T1218"
152name = "System Binary Proxy Execution"
153reference = "https://attack.mitre.org/techniques/T1218/"
154
155
156[rule.threat.tactic]
157id = "TA0005"
158name = "Defense Evasion"
159reference = "https://attack.mitre.org/tactics/TA0005/"
160[[rule.threat]]
161framework = "MITRE ATT&CK"
162[[rule.threat.technique]]
163id = "T1567"
164name = "Exfiltration Over Web Service"
165reference = "https://attack.mitre.org/techniques/T1567/"
166
167
168[rule.threat.tactic]
169id = "TA0010"
170name = "Exfiltration"
171reference = "https://attack.mitre.org/tactics/TA0010/"
Triage and analysis
Investigating Potential File Transfer via Certreq
Certreq is a command-line utility in Windows operating systems that allows users to request and manage certificates from certificate authorities. It is primarily used for generating certificate signing requests (CSRs) and installing certificates. However, adversaries may abuse Certreq's functionality to download files or upload data to a remote URL by making an HTTP POST request.
This rule identifies the potential abuse of Certreq to download files or upload data to a remote URL.
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 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.
- Identify the user account that performed the action and whether it should perform this kind of action.
- Contact the account owner and confirm whether they are aware of this activity.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
- Examine the details of the dropped file, and whether it was executed.
- Check the reputation of the domain or IP address used to host the downloaded file or if the user downloaded the file from an internal system.
- Examine the host for derived artifacts that indicate suspicious activities:
- Analyze the file 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's
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's
- 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
- This activity is unusual but can be done by administrators. Benign true positives (B-TPs) can be added as exceptions if necessary.
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.
- 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.
- 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
- Adding Hidden File Attribute via Attrib
- Attempt to Establish VScode Remote Tunnel
- Attempt to Install Kali Linux via WSL
- Bypass UAC via Event Viewer
- Clearing Windows Console History