{"description":"Trending threats, MITRE ATT\u0026CK coverage, and detection metadata — refreshed continuously.","feed_url":"https://feed.craftedsignal.io/tags/xp_cmdshell/","home_page_url":"https://feed.craftedsignal.io/","items":[{"_cs_actors":[],"_cs_cves":[],"_cs_exploited":false,"_cs_products":["SQL Server"],"_cs_severities":["medium"],"_cs_tags":["persistence","sql-server","xp_cmdshell","windows"],"_cs_type":"threat","_cs_vendors":["Microsoft"],"content_html":"\u003cp\u003eThe xp_cmdshell extended stored procedure in Microsoft SQL Server allows execution of operating system commands from within the SQL Server environment. Although disabled by default, its use can provide a direct pathway for attackers to run arbitrary commands on the underlying system with the privileges of the SQL Server service account. This account often has elevated privileges, allowing attackers to escalate their access and establish persistence mechanisms. This activity has been observed in intrusions where attackers seek to maintain control over compromised systems. Defenders should closely monitor for the enabling and use of xp_cmdshell, especially when combined with other suspicious activity.\u003c/p\u003e\n\u003ch2 id=\"attack-chain\"\u003eAttack Chain\u003c/h2\u003e\n\u003col\u003e\n\u003cli\u003eAn attacker gains initial access to a vulnerable SQL Server instance, possibly through SQL injection or compromised credentials.\u003c/li\u003e\n\u003cli\u003eThe attacker attempts to enable the xp_cmdshell stored procedure using \u003ccode\u003esp_configure 'xp_cmdshell', 1; RECONFIGURE;\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003eThe attacker uses xp_cmdshell to execute reconnaissance commands, such as \u003ccode\u003exp_cmdshell 'whoami'\u003c/code\u003e or \u003ccode\u003exp_cmdshell 'net user'\u003c/code\u003e to gather information about the system and user context.\u003c/li\u003e\n\u003cli\u003eThe attacker uses xp_cmdshell to download and execute a malicious payload (e.g., using \u003ccode\u003ecertutil.exe\u003c/code\u003e to download a file).\u003c/li\u003e\n\u003cli\u003eThe attacker establishes persistence by creating a scheduled task via xp_cmdshell executing the \u003ccode\u003eschtasks\u003c/code\u003e command. For example: \u003ccode\u003exp_cmdshell 'schtasks /create /tn \u0026quot;Malicious Task\u0026quot; /tr \u0026quot;C:\\\\Windows\\\\Temp\\\\evil.exe\u0026quot; /sc ONLOGON /ru SYSTEM'\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003eThe scheduled task executes upon system logon, providing persistent access for the attacker.\u003c/li\u003e\n\u003cli\u003eThe attacker uses the persistent access to deploy additional tools or exfiltrate data.\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch2 id=\"impact\"\u003eImpact\u003c/h2\u003e\n\u003cp\u003eSuccessful exploitation enables attackers to execute arbitrary commands with elevated privileges on the SQL Server host. This can lead to data theft, system compromise, and the establishment of persistent backdoors. Lateral movement within the network is also possible, leveraging the compromised SQL Server as a pivot point. While specific victim counts and sectors are not provided, any organization using MSSQL Server is potentially vulnerable.\u003c/p\u003e\n\u003ch2 id=\"recommendation\"\u003eRecommendation\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003eDeploy the Sigma rule \u0026ldquo;Detect Suspicious xp_cmdshell Usage\u0026rdquo; to your SIEM to detect attempts to use xp_cmdshell for command execution.\u003c/li\u003e\n\u003cli\u003eDisable the xp_cmdshell stored procedure unless absolutely necessary. If required, implement strict monitoring and auditing of its usage (reference: rule description).\u003c/li\u003e\n\u003cli\u003eMonitor for process creation events with a parent process of \u003ccode\u003esqlservr.exe\u003c/code\u003e, specifically looking for command-line arguments indicative of exploitation (reference: Sigma rule).\u003c/li\u003e\n\u003cli\u003eEnsure SQL servers are not directly exposed to the internet and implement strict access controls, using allowlists to restrict connections to legitimate sources (reference: the \u0026ldquo;Response and remediation\u0026rdquo; section).\u003c/li\u003e\n\u003c/ul\u003e\n","date_modified":"2024-01-03T12:00:00Z","date_published":"2024-01-03T12:00:00Z","id":"/briefs/2024-01-mssql-xp-cmdshell-persistence/","summary":"Attackers may leverage the xp_cmdshell stored procedure in Microsoft SQL Server to execute arbitrary commands for privilege escalation and persistence, often bypassing default security configurations.","title":"MSSQL xp_cmdshell Stored Procedure Abuse for Persistence","url":"https://feed.craftedsignal.io/briefs/2024-01-mssql-xp-cmdshell-persistence/"}],"language":"en","title":"CraftedSignal Threat Feed — Xp_cmdshell","version":"https://jsonfeed.org/version/1.1"}