Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1234

How to prevent ANY use of xp_CmdShell? Expand / Collapse
Author
Message
Posted Wednesday, October 23, 2013 11:41 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 5:18 PM
Points: 504, Visits: 1,465
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

Post #1507773
Posted Wednesday, October 23, 2013 11:55 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:25 AM
Points: 7,070, Visits: 12,523
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

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1507777
Posted Wednesday, October 23, 2013 12:00 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 5:18 PM
Points: 504, Visits: 1,465
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.
Post #1507779
Posted Wednesday, October 23, 2013 12:25 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:25 AM
Points: 7,070, Visits: 12,523
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

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1507788
Posted Thursday, October 24, 2013 5:13 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 10:06 PM
Points: 8,283, Visits: 8,733
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
Post #1508298
Posted Thursday, October 24, 2013 7:43 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:25 AM
Points: 7,070, Visits: 12,523
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

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1508312
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse