| ID | Technique | Tactic |
|---|---|---|
| T1505.001 | SQL Stored Procedures | Persistence |
Detection: Windows Sqlservr Spawning Shell
Description
This analytic detects instances where the sqlservr.exe process spawns a command shell (cmd.exe) or PowerShell process. This behavior is often indicative of command execution initiated from within the SQL Server process, potentially due to exploitation of SQL injection vulnerabilities or the use of extended stored procedures like xp_cmdshell.
Search
1
2| tstats `security_content_summariesonly` count min(_time) as firstTime max(_time) as lastTime FROM datamodel=Endpoint.Processes
3 WHERE Processes.parent_process_name="sqlservr.exe" `process_cmd`
4 OR
5 `process_powershell`
6 BY Processes.action Processes.dest Processes.original_file_name
7 Processes.parent_process Processes.parent_process_exec Processes.parent_process_guid
8 Processes.parent_process_id Processes.parent_process_name Processes.parent_process_path
9 Processes.process Processes.process_exec Processes.process_guid
10 Processes.process_hash Processes.process_id Processes.process_integrity_level
11 Processes.process_name Processes.process_path Processes.user
12 Processes.user_id Processes.vendor_product
13
14| `drop_dm_object_name(Processes)`
15
16| `security_content_ctime(firstTime)`
17
18| `security_content_ctime(lastTime)`
19
20| `windows_sqlservr_spawning_shell_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Sysmon EventID 1 | 'XmlWinEventLog' |
'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational' |
|
| Windows Event Log Security 4688 | 'XmlWinEventLog' |
'XmlWinEventLog:Security' |
Macros Used
| Name | Value |
|---|---|
| process_cmd | (Processes.process_name=cmd.exe OR Processes.original_file_name=Cmd.Exe) |
| windows_sqlservr_spawning_shell_filter | search * |
windows_sqlservr_spawning_shell_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.
Annotations
Default Configuration
This detection is configured by default in Splunk Enterprise Security to run with the following settings:
| Setting | Value |
|---|---|
| Disabled | true |
| Cron Schedule | 0 * * * * |
| Earliest Time | -70m@m |
| Latest Time | -10m@m |
| Schedule Window | auto |
| Creates Risk Event | False |
Implementation
To implement this detection, you need to be ingesting endpoint data that captures process creation events, specifically the parent-child process relationships. Ensure that you are collecting Sysmon Event ID 1 or Windows Event Log Security 4688 events. The data should be mapped to the Endpoint data model in Splunk.
Known False Positives
Legitimate administrative activities or monitoring tools might occasionally spawn command shells from sqlservr.exe. Review the process command-line arguments and consider filtering out known legitimate processes or users.
Associated Analytic Story
References
Detection Testing
| Test Type | Status | Dataset | Source | Sourcetype |
|---|---|---|---|---|
| Validation | ✅ Passing | N/A | N/A | N/A |
| Unit | ✅ Passing | Dataset | XmlWinEventLog:Microsoft-Windows-Sysmon/Operational |
XmlWinEventLog |
| Integration | ✅ Passing | Dataset | XmlWinEventLog:Microsoft-Windows-Sysmon/Operational |
XmlWinEventLog |
Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI.
Alternatively you can replay a dataset into a Splunk Attack Range
Source: GitHub | Version: 6