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


How to call a batch file to execute from an SP


How to call a batch file to execute from an SP

Author
Message
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: 15055 Visits: 14396
Sergiy (3/24/2013)
opc.three (3/24/2013)
The fact is that a system with xp_cmdshell disabled has less security exposures, has less vulnerabilities and is more auditable than a system where it is enabled.


OK.
I'm an intruder on your system.

If I'm connected using non-systemadmin credentials I cannot execute any call to xp_cmdshell anyway, and I cannot get privileges associated with it.
So, it does not really matter if it's disabled or enabled - I won't be able even to figure out that.

Now, if I'm connected as a systemadmin. First thing I will do is
EXEC sp_configure 'xp_cmdshell', 1


Immediately followed by
RECONFIGURE  WITH OVERRIDE


Voilà!
xp_cmdshell is enabled, no matter what state it was 3 ms ago.

So, where those promissed "less security exposures, has less vulnerabilities"?

You're still hung up on external scenarios.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
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: 15055 Visits: 14396
Sergiy (3/24/2013)
opc.three (3/24/2013)
The point is, xp_cmdshell is a blunt tool that cannot be audited and allows people to run commands as someone else, possibly with more permissions than their own, without the possibility of being detected or tracked.


Would it be wiser to limit the privileges associated with the account running sqlserver service to its jon related tasks?
Read from there, write there, check on that location, execute that task.
That's it. The list is closed.
If you need to do something else - talk to your system administrator, as they say in MS messages.

This layer would be definitely harder to pass than to enable xp_cmdshell, don't you think?



All of those things should be done in addition to leaving xp_cmdshell disabled.

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

Group: General Forum Members
Points: 10532 Visits: 11964
opc.three (3/24/2013)
You're still hung up on external scenarios.

Not really.
Replace "intruder" with "employee gone nuts".
What does it change?
Sergiy
Sergiy
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10532 Visits: 11964
opc.three (3/24/2013)
All of those things should be done in addition to leaving xp_cmdshell disabled.

If those things are done there is no point of disabling xp_cmdshell.
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: 15055 Visits: 14396
Sergiy (3/24/2013)
opc.three (3/24/2013)
You're still hung up on external scenarios.

Not really.
Replace "intruder" with "employee gone nuts".
What does it change?

Not much you can do there. But consider the employee in the sysadmin Role looking to steal data without being detected. Please re-read earlier posts. Its all laid out there. It depends on what you're protecting against and you're only focusing on the person who blazes in, does damage or steals, and doesn't care much about being detected either because they fade back to the shadows of the internet, or they are a nutso employee who just wants to do damage.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
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: 15055 Visits: 14396
Sergiy (3/24/2013)
opc.three (3/24/2013)
All of those things should be done in addition to leaving xp_cmdshell disabled.

If those things are done there is no point of disabling xp_cmdshell.

Why do you need it? There is no need to enable it. What would you need it for if things are locked down to the point where the engine only needs to talk to the file system for writing backups, logs and trace files or other system related operations to allow the instance to function?

This conversation began discussing cross-server exchanges of data, I.e. Using xp_cmdshell to facilitate an ETL system.

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

Group: General Forum Members
Points: 10532 Visits: 11964
opc.three (3/24/2013)
But consider the employee in the sysadmin Role looking to steal data without being detected.


And?
How adding an "sp_configure" command to a script used for stealing data will help to detect who's behind the SA user?
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: 15055 Visits: 14396
Sergiy (3/24/2013)
opc.three (3/24/2013)
But consider the employee in the sysadmin Role looking to steal data without being detected.


And?
How adding an "sp_configure" command to a script used for stealing data will help to detect who's behind the SA user?

Version control. Change management processes. Code review. Layers...

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

Group: General Forum Members
Points: 10532 Visits: 11964
opc.three (3/24/2013)
[quote]Sergiy (3/24/2013)
Version control. Change management processes. Code review. Layers...


What all these words have to do with stealing data by launching an ad-hoc query using SA privilages?

Or you really believe someone with such intentions would submit such code for peer review before committing???
w00t
Steve JP
Steve JP
SSC Journeyman
SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)

Group: General Forum Members
Points: 95 Visits: 328
Over the years I have isolated xp_cmdshell, xp_sendmail etc from users and 3rd Party applications by using a stored procedure in front of the system procs. All inputs are checked and the made safe and logged.

Of course another option is to start using assemblies on some of this but then that starts meaning trusted databases and code that cant be read. These are different risk and potentially mopre serious risks.

It is better to help the developers/3rd Parties to change the code to something safer than just saying no. Minimal change is easier to adapt to then a completely different method accompanied by a steep learning curve
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