ID | Technique | Tactic |
---|---|---|
T1505.001 | SQL Stored Procedures | Persistence |
Detection: Windows SQL Server xp_cmdshell Config Change
Description
This detection identifies when the xp_cmdshell configuration is modified in SQL Server. The xp_cmdshell extended stored procedure allows execution of operating system commands and programs from SQL Server, making it a high-risk feature commonly abused by attackers for privilege escalation and lateral movement.
Search
1`wineventlog_application` EventCode=15457
2| rex field=EventData_Xml "<Data>(?<config_name>[^<]+)</Data><Data>(?<new_value>[^<]+)</Data><Data>(?<old_value>[^<]+)</Data>"
3| rename host as dest
4| where config_name="xp_cmdshell"
5| eval change_type=case( old_value="0" AND new_value="1", "enabled", old_value="1" AND new_value="0", "disabled", true(), "modified" )
6| eval risk_score=case( change_type="enabled", 90, change_type="disabled", 60, true(), 70 )
7| eval risk_message="SQL Server xp_cmdshell was ".change_type." on host ".dest
8| stats count min(_time) as firstTime max(_time) as lastTime by dest EventCode config_name change_type risk_message risk_score
9| `security_content_ctime(firstTime)`
10| `security_content_ctime(lastTime)`
11| `windows_sql_server_xp_cmdshell_config_change_filter`
Data Source
Name | Platform | Sourcetype | Source |
---|---|---|---|
Windows Event Log Application 15457 | 'XmlWinEventLog' |
'XmlWinEventLog:Application' |
Macros Used
Name | Value |
---|---|
security_content_ctime | convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$) |
windows_sql_server_xp_cmdshell_config_change_filter | search * |
windows_sql_server_xp_cmdshell_config_change_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 Notable | Yes |
Rule Title | %name% |
Rule Description | %description% |
Notable Event Fields | user, dest |
Creates Risk Event | True |
Implementation
To successfully implement this detection, you need to be ingesting Windows Application Event Logs from SQL Server instances where SQL Server is installed. The detection specifically looks for EventID 15457 which indicates configuration changes to extended stored procedures.
Known False Positives
Database administrators may legitimately enable xp_cmdshell for maintenance tasks, such as database maintenance scripts requiring OS-level operations, legacy applications, or automated system management tasks; however, this feature should generally remain disabled in production environments due to security risks. To reduce false positives, document when xp_cmdshell is required, monitor for unauthorized changes, create change control procedures for xp_cmdshell modifications, and consider alerting on the enabled state rather than configuration changes if preferred.
Associated Analytic Story
Risk Based Analytics (RBA)
Risk Message:
SQL Server xp_cmdshell configuration was $change_type$ on host $dest$, which could indicate an attempt to gain operating system command execution capabilities
Risk Object | Risk Object Type | Risk Score | Threat Objects |
---|---|---|---|
dest | system | 90 | No Threat Objects |
config_name | other | 90 | No Threat Objects |
References
Detection Testing
Test Type | Status | Dataset | Source | Sourcetype |
---|---|---|---|---|
Validation | ✅ Passing | N/A | N/A | N/A |
Unit | ✅ Passing | Dataset | XmlWinEventLog:Application |
XmlWinEventLog |
Integration | ✅ Passing | Dataset | XmlWinEventLog:Application |
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: 1