SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to prevent ANY use of xp_CmdShell?


How to prevent ANY use of xp_CmdShell?

Author
Message
dan-572483
dan-572483
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1413 Visits: 1999
Not to interject a dumb quesiton into this but what does this mean?


name minimum maximum config_value run_value
xp_cmdshell 0 1 0 0


Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15611 Visits: 14396
It means xp_cmdshell is disabled within this instance, the default.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
dan-572483
dan-572483
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1413 Visits: 1999
Does this not prevent use of xp_CmdShell by SAs, which was the original quesiton?

This reminds me of a question a few years ago about how to keep SAs from being able to view the data in tables. The way to keep people from having access to 100 percent of functionality is to not put them in the sysadmin group or give them the sa password. At a certain point, you just have to trust certain people.
Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15611 Visits: 14396
No, it does't. A member of the sysadmin Role can simply enable it.

You're conflating multiple issues. There is a difference between trusting someone to do all operations within the scope of the database engine, e.g. see all data in all tables within all databases, and trusting someone to do all operations on the server on which SQL Server is hosted, e.g. have access to xp_cmdshell to reach a cmd-shell command line on the host server.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Tom Thomson
Tom Thomson
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14836 Visits: 12238
opc.three (10/23/2013)
No, it does't. A member of the sysadmin Role can simply enable it.

You're conflating multiple issues. There is a difference between trusting someone to do all operations within the scope of the database engine, e.g. see all data in all tables within all databases, and trusting someone to do all operations on the server on which SQL Server is hosted, e.g. have access to xp_cmdshell to reach a cmd-shell command line on the host server.

The privileges obtainable using XP_CMDSHELL are limited to those of the SQL Server Service account. If these are not sufficient to do all operations on the machine, xp_cmdshell doesn't allow a SQL Server admin to do all operations on it. Of course if you choose to run the SQL Service under an enterprise adminiistrator, or domain administrator, or even a local administrator you are giving SQL Admins a lot of privileges, but why would you want to run it that way? Is it too much effort to set up an account specifically to run the SQL Service under and not give it excessive privileges? I found it easy to do that with SQL 2008 and SQL 2008 R2, and SQL 2012 appears to do it for me unless I override it, making it even easier. It was of course a nightmare in SQL 2000, and I never used 2005 so I don't know what it was like there.

The other thing to remember is that if you run SQL Server Agent under a privileged account then everyone with access to sp_add_jobstep can use those privileges (unless you set up an agent proxy, but of course that won't stop SA); that's another account that ideally shouldn't be a member of any administrator group.

Tom

Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15611 Visits: 14396
L' Eomot Inversé (10/24/2013)
opc.three (10/23/2013)
No, it does't. A member of the sysadmin Role can simply enable it.

You're conflating multiple issues. There is a difference between trusting someone to do all operations within the scope of the database engine, e.g. see all data in all tables within all databases, and trusting someone to do all operations on the server on which SQL Server is hosted, e.g. have access to xp_cmdshell to reach a cmd-shell command line on the host server.

The privileges obtainable using XP_CMDSHELL are limited to those of the SQL Server Service account. If these are not sufficient to do all operations on the machine, xp_cmdshell doesn't allow a SQL Server admin to do all operations on it. Of course if you choose to run the SQL Service under an enterprise adminiistrator, or domain administrator, or even a local administrator you are giving SQL Admins a lot of privileges, but why would you want to run it that way? Is it too much effort to set up an account specifically to run the SQL Service under and not give it excessive privileges? I found it easy to do that with SQL 2008 and SQL 2008 R2, and SQL 2012 appears to do it for me unless I override it, making it even easier. It was of course a nightmare in SQL 2000, and I never used 2005 so I don't know what it was like there.

I am aware of which security contexts the cmd.exe process can run under when created using xp_cmdshell. you mentioned the proxy account. Note we only have one proxy account per instance and naturally one service account per instance. That is not nearly granular enough to allow for processes that use xp_cmdshell numering more than two to be tightly controlled because inevitably they'll have more permissions than are necessary for them to do their work.

When you consider the most common use cases for employing the extended stored procedure it is an easy leap to elevating the service account's permissions to allow for copying backups to a network share, writing a file by calling bcp with the out option to somewhere, etc.


The other thing to remember is that if you run SQL Server Agent under a privileged account then everyone with access to sp_add_jobstep can use those privileges (unless you set up an agent proxy, but of course that won't stop SA); that's another account that ideally shouldn't be a member of any administrator group.

Agreed. SQL Agent is another attack vector that demands attention.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search