SQL Server security best practice

Security! This is the word comes in mind of every concerned person when it come...

Change the Collation Settings in MS SQL Server

This post will show you how to change the collation settings in MS SQL Server for specific database...

Resolve collation conflict

In this post I will show you how you can resolve collation conflict error...

Book: SQL Server 2008 High Availability

In this book I have tried to cover every single piece of information that might requires for installing and configuring SQL Server HA option like Clustering, Replication, Log Shipping and Database Mirroring...

Why to recompile Stored Procedure

Generally, we create views and stored procedures (proc here after) ...

Showing posts with label securing sql server. Show all posts
Showing posts with label securing sql server. Show all posts

11/03/2013

SQL Server–Security Risk Assessment PMP Way

clip_image001Recently I had a chance to speak my friend Ashish Sharma who is my colleague too. We were discussing Project Management topics (he recently passed PMP and ACP). Our discussion ended at very interesting topic – RISK Assessment.
Definition: According to PMBOK, Projects can have unforeseen event or activity that can impact the project’s progress, result or an outcome in negative or positive way. Further, A Risk can be assessed using two factors – impact and probability. Determining the quantitative or qualitative value of risk related to a concrete situation and recognized threats is known as Risk Assessment.
So, coming to the point, how do we do Risk Assessment for Database systems, especially SQL Server ?
I myself have never come to situation where I have created or used Risk Assessment Register for SQL Server. I was thinking is there some readily available Risk Assessment Register / document somewhere? Hence, I have decided to research little more on it. I found absolutely nothing on this very topic. However, searching for different term - SQL Server security, and Risk Assessment – none found.
After spending some time researching I have found a good sample document for Risk Assessment Register that we can use, you can download it from here.
Now, this is what we have is Risk Register, how about threats? Sometime back, in 2009 I have wrote an article on SQL Server Security, using that article I have tried to pen down some threats that I can think off at this moment, they are:
Possible Threats Risk Mitigation
Virus Attack Install AV on DB Server however do not forget to exclude SQL server files
Unauthorised Logins Always use Audit (C2, Windows, SQL or both) failed login attempts and analyze them regularly. Always, rename SA / Admin account and use strong password mechanism for all the servers. If possible always try to use domain authenticated acconts.
MiM Attack To metigate MiM attach do following :
  • Isolate database server from Application / IIS Server
  • Configure SQL Server to use non-default port
  • Use Encryption / SSL
  • Use Firewall inbound / outbound rules
Root Access To avoid someone getting root access do following:
  • Disable / Rename in-built Admin account
  • Grant least access to Service Account
  • Use strong / random password
SQL Injection Do following:
  • Avoid using Dynamic SQL when you can
  • use parameterized query / stored procedure 3) Always validate the value at form level before it's being passed to database server
  • Refer above items
Known Configuration Always try to customize default configuration if you can, for example:
  • Run SQL server on non standard port
  • disable / rename SA account
  • Disable xp_cmdshell and other extended procedures

References :
http://en.wikipedia.org/wiki/Risk_assessment
http://en.wikipedia.org/wiki/Project_risk_management
http://www.brighthubpm.com/risk-management/3247-creating-a-risk-register-a-free-excel-template/
photo credit: kenteegardin via photopin cc
-- Hemantgiri S. Goswami (http://www.sql-server-citation.com )

1/22/2010

Embed security and secure your data

Security!! A word – that everybody want, whatever it may for - a life, money or a job. In an IT world this term is often used, and asked by the client, the customer or the end user because it is closely attached to the information they are providing or storing or exchanging with each other. It can create a chaos if an ounce of the information is leaked or spread publicly; refer the case about classified US Military info available, reported in July-2007 by Network World.  

So, what we really have to care about that every piece of work that we do should be secure - by default, and this applies to every technology. That means whatever we work on, we should follow and implement the security policies to build the robust and secure product. Recently, I was researching about security and I found a link about Microsoft Security Development Lifecycle (SDL). It is since 2004 that Microsoft has made SDL mandatory to follow for its entire product range.  I would advise you to follow the same when you make a product for a business environment, communication software such as messenger or dealing with the sensitive information. 

Since 2004, most of the product from Microsoft has built-in features to tighten security. This applies to SQL server as well; you can see that SQL Server 2005 has great security features i.e. you can enforce password policy on your database server to ensure that the passwords that your users are crating are strong. Apart from this   now it is not necessary to assign system administrator rights to run profile, the only permission user requires is ALTER TRACE to run profiler. You may refer my article on how to secure SQL server for more pointers.

Microsoft publish security bulletin every month which will give advice you if you required installing any patch on your system. And to make this procedure easy for Windows operating systems and Office product Microsoft is offering Security Compliance Management Toolkit Series. Also to keep your system free from Viruses or malware Microsoft Assessment and Planning (MAP) toolkit is useful.

So, all in all we all should be more cautious when we are dealing with sensitive data and should improve by following SDL.

5/05/2009

How to Secure SQL Server - SQL Server Security Criteria

Security! This is the word comes in mind of every concerned person when it comes to store, access and share the data and database or database server. At times when applications are run in the geographically restricted area, there were less chance of its exploitation and with spread of internet and the availability of application over the internet, security of data, databases and database servers has become vital.

Why SQL Server Security has been so much important!!
Well, for every organization or institute or company or government has there data that is vital to them, and not to be accessed by the authorized person or entity only. And that is vital to set some security standards for such a critical data so that you can prevent your data as much as you can with proper security mechanism and set of standards within organization and in your scope for MS SQL Server Security.

I have pen down some pointers/criteria that requires serious consideration when it comes to secure MS SQL Server.

1. Guest User Account: It is always good practice to disable guest user account; this will keep our server robust from skilled user that can make use of guest user account to gain access over the server.

Skilled user always looked into a guest user account to establish a NULL session with which, he/she can compromise server.

2. Public Account: Do not grant permission to Public role, as every single user is a member of this role; hence if you grant any permission to this role it will be available to every user and that will breach security standards.

3. System Administrator Account: We would need to rename and disable System Administrator account as best security practice; to do so we need to create integrated account that has SA permissions then create users and assign them appropriate permission based on the fact who need to access what data!! One of the best practice is also to rename or disable the SA account, it is advisable that we follow this best practice. However, make sure you have one account having equivalent permissions as of SA, also advisable to remove "Built-in\Administrator" group.

4. Application Roles: While answering threads at Microsoft/Non-Microsoft Forums for SQL Server most of the time what I’ve found is developers/users/dba(s) just avoid creating and/or maintaining schemas/application roles. Actually it does lots of helps to us in terms of rework (granting and/or revoking permissions) and easy manageability of sql users. Above all if guest user is not mapped to application role of database, guest user cannot access to database object; we can audit application role’s activity also.

5. Strong Password Mechanism: This is the most vulnerable thing; if our password mechanism is not that strong, one can easily get into our box and steal our data or can do whatever he/she wants to do with; sometimes we may found users with NULL/TRIVIAL passwords. Again, this is much more critical if application is accessed over Internet we are openly inviting thieves!!!

6. Access port: By default SQL Server 2000 listens to TCP port 1433 and UDP port listens to 1434 which is known to everybody; we would need to change it to another port then default and firewall rule should be created accordingly for exceptions. SQL Server 2005 listens to dynamic port*

* Whenever SQL Server 2005 names instance starts it get port automatically, but as always you may change it to static. Refer below http://blogs.msdn.com/sqlserverfaq/archive/2008/06/02/how-to-change-the-dynamic-port-of-the-sql-server-named-instance-to-an-static-port-in-a-sql-server-2005-cluster.aspx

7. NTFS file system: NTFS file system is introduced in early 1993 with launch of Windows NT 3.5, this is the file system that has some good feature that were not available in FAT 16 and FAT 32 file system. File and Folder level security is the key benefit of this file system which also benefited us to keep our SQL Server files secure by assigning appropriate permissions.

8. Updating Server: Microsoft keep releasing service packs (SP) and hot fix time-to-time to keep software more secure, robust and bug free. It is recommended that we should update our box with latest SP(s) and hot-fix on regular basis.

9. Audit: We should enable audit for login failures and warning errors and need to be monitored on daily basis so that if any error, login failure or suspected login attempt will be notified and we could take necessary action based on the fact available in Log, this way we can foresee any probable vulnerability or can avoid it to be happened.

10. Integrated Logins: Using this feature one can assure him/herself that sql box is more secure; integrated/windows authentication* uses domain account to access server, database and database objects. Here, whenever user tries to access sql box his/her account is validated by domain controller first and then permit or denying to access the system without requiring separate login id and password; after this it will check with SQL Server for kind of permission this user(s) has.

The other benefit is one can use encrypted password, various handshake methods like PKI, Kerberos, EAP, SSL Certificates, NAP, LDP and IPSec policy; this will ensure our highly critical data are being sent securely over the network.

* http://msdn.microsoft.com/en-us/library/aa905171(SQL.80).aspx

http://msdn.microsoft.com/en-us/library/aa905172(SQL.80).aspx

http://msdn.microsoft.com/en-us/library/aa905190(SQL.80).aspx

11. Instances: We can create different Instances to isolate development/production environment from each other; and / or isolating users from accessing database which are not meant for them. This can be done by application roles/fixed DB / fixed server roles but using instances we can hide name of the databases from the users this way they don’t even come to know which databases are there on server and who is accessing which database.

12. Service account: Always use least privileged user account to start the server and agent service on the server. Domain account with the local admin privilege is enough to start the services; domain user account for services is required if we would have to work on some special services which requires network access also like replication, log shipping, mirroring, cluster, remote procedure calls, backing up-restoration on or from network and remote data access.

13. Network Library: Don’t installed and allowed network library except those are required.

14. Isolated from IIS: Though we can have both SQL Server and IIS on single machine; it is advisable to keep them on separate machine. The idea is; even if IIS server is compromise our database(s) are secure, the other benefit is if more memory and processer resource is eaten by IIS server SQL box will not suffer.

15. Stored Procedure: We should have to make a practice to wrap DML statements in SP(s) to avoid SQL injection.

16. Monitoring SQL Server and Windows Event Viewer: We shall keep out eye on SQL Error Log and Windows Event Viewer for any suspicious activity on daily basis so that we can take corrective action(s) as soon as it is identified.

17. Encrypting data: We should use WITH ENCRYPTION option to keep our code safe; and for data we could use symmetric encrypted columns in SQL Server 2005 or third party tools like activecrypt for data encryption in SQL Server 2000.

18. Linked server: Prevent access to linked server from those users who don’t need to access by assigning proper privileges.

19. System Stored Procedure(s): System stored procedures (SP) like xp_cmdshell, xp_regread, xp_regwrite needs to be restricted to access. Using this SP(s) one can easily read, modifies or deletes registry information or can manipulate system information.

20. Anti Virus: We should install Antivirus on SQL Box and exclude sql server database files; this way we can be assure from Virus/Trojan/Malware/Spam attacks on our servers that could harm our database files.

Conclusion:
As the time passes Securing data has become the most vital part, and we must agree and honor it. Because this is the information that contains our financial, social, business and historical data; and as a DBA it is our prime responsibility to make sure that this has been taken care and secure enough. These are the key points that I’ve collected so far, if anybody would like to draw my attention to some point that I might have missed out can write back there comments here.

Update: Edited point 3, added a line saying "SA" account should be renamed or disabled according to best practice. 
Updated on 2nd March 2010
photo credit: david_shankbone via photopin cc