Recently we have disabled a module which is dependent on xp_cmdshell. Though we are not directly using the xp_cmdshell (instead we are using the proxy), we would now like to disable the xp_cmdshell itself.

Can anyone explain to me with a simple scenario based on the the statement below, why some people are for xp_cmdshell and most of the people are against xp_cmdshell?

"xp_cmdshell" is an extended stored procedure provided by Microsoft and stored in the master database. This procedure allows you to issue operating system commands directly to the Windows command shell via T-SQL code. It is dangerous as it can be used by trojans and worms to gain access to the system.

Reference: Restrict Microsoft SQL Server XP_CMDSHELL Procedure (Trend Micro)

  1. Though only SQL Server admin can use it, why people are still against ?
  2. (Not in a negative sense) Is it really possible for SQL Injection using xp_cmdshell? Any simple hint / example of a scenario of SQL Injection via xp_cmdshell, I just want to understand the background.
  3. What are the dangerous Windows OS commands one can think of?

Apologize, though there are many articles and write-ups on xp_cmdshell, I am bit confused on what are the dangerous stuff it could do.

  • 2
    xp_cmdshell 'my_ransomware_encrypt.exe c:' could be one of those commands after a SQL injection used xp_cmdshell to download the ransomware binaries (e.g. using powershell or any other Windows built-in tools) – a_horse_with_no_name Mar 26 '18 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.