How can I encrypt my database?

Filed under: Administration, Backup and Restore, Database Design, Security — Jason at 11:34 am on Monday, October 13, 2008

This is a very general question that someone could certainly write a book on but I’ll go at answering it by providing a few options and explaining the pro’s and con’s of each solution.  The following list is by no means comprehensive.

The first question you need to ask yourself before going on this journey is where does the encryption need to occur and who are you protecting the data from.  These two questions will drive the amount of effort and complexity required in building a solution.

1)  In database encryption.  The database is encrypted in the database and is viewable to no-one unless they have access to the encryption key.  The data could be encrypted at the application level by first running the data through an encryption algorithm before inserting into the database or the data can be encrypted using SQL Server 2005’s column level encryption or SQL Server 2008’s transparent data encryption.  Using in database encryption is the most secure option in that it can be leveraged to protect sensitive data from anyone that gains access to the database engine itself (whether valid or invalid access) however it has significant performance and scalability caveats.  Encrypting at the application level basically ensures that SQL Server will not be able properly index the data and therefore query perofmance may be dreadful with large data sets.  Leveraging column level encryption or TDE also will introduce query processing overhead and adversely affects the performance of your queries but not to the same extent.   Another drawback of In Database encrption is that it renders backup compression (whether through SQL Server 2008 or a third party backup product or winzip) obsolete.  Encrypted data is not compressible, therefore the size of your encrypted database will roughly equal the size of your backup files regardless of the compression technology used.

2)  If you do not need to secure data inside of the database but want to secure data once it leaves the database, a good solution would be to leverage a third party backup solution such as LiteSpeed.  These solutions will compress and also encrypt backup data in memory so that it is secured as soon as it leaves the database.  This is an attractive option to companies that store backups on network devices and are worried about internal or external users gaining access to network resources and therefore having direct access to backup files.  If you think that native backup files are secured, try opening a small database backup file in notepad.  You will see that all of the data is stored in plain text.  If you have a copy of pubs lying around from the SQL 2000 days you can back it up, open the backup file in notepad, search for “Smith” and you will see Smith’s social security number right there.  This method of database encryption will not secure the data in the database, so anyone who gains database access has free reign on your data, but thats what DBA’s are for right???

3)  A third option, and the last that we will discuss here, is to leverage encryption at the tape level.  Most organizations take their disk based backups and eventually migrate them to tape, where the backups files are then encrypted and eventually moved to offsite storage.  This should be a bare minimum for any SQL Server as once a tape leaves offsite anything could happen to it.  There have been many major news stories recently discussing companies that have had backup tapes lost or stolen and without leveraging at a minimum the tape systems encryption, that data is available to anyone that may “find” a backup tape.  Tape level encryption does nothing to protect the database info inside of the database or the backup data inside of a companies network, but it does protect the data once it is transported offsite.  The nice advantage of this as well as the previous option is that they impose no overhead on standard database workload, they simply may add some overhead to your backup time depending on the level of encyption that you are performing.

Hopefully this brief rundown of database encryption options has given you enough info to get started decideing which implentation strategy is best for you, and as always if you have any further questions, feel free to submit them.

Technorati Tags: , , ,

How do I query DB2 data from SQL Server?

Filed under: Administration, Database Design, I'm a Newbie, Internals and Architecture, Programming, Security — Jason at 3:15 pm on Wednesday, August 20, 2008

Q:  We use DB2 Connect to access DB2 from MS Access. Do we need this for SQL Server also or does SQL Server have a built-in interface or do we need something else?

A: No you do not need to use DB2 Connect in able to access DB2 data within SQL Server.  SQL Server supports linked servers which allow you to register a remote data source in SQL Server and execute queries against it.  Linked servers can be remote SQL Server instances or instances of Oracle, DB2, Sybase, MySQL, etc…  As long as there is a supported OLEDB driver for the data source you can add it as a linked server.  There is a blog post you can read here:

http://blogs.msdn.com/dotnetinterop/archive/2006/01/20/defining-a-db2-as-a-linked-server.aspx

that walks you through the process of setting up a linked server to DB2 and you can also look up Linked Servers in books online for more information.

CSI:DBA - finding out who made schema changes

Filed under: Administration, Security — Brent Ozar at 9:29 am on Wednesday, July 16, 2008

Detective By Accident - that’s what DBA really stands for, not Database Administrator.  Come on, if it was really Database Administrators, we’d be DA’s.  Granted, most of us don’t look like Warrick Brown or Sara Sidle, but when something disappears in the datacenter, people pick up the phone and call us.

On July 24th, Jason Hall and I are doing a webcast called CSI:DBA - Going Back in Time to Understand What Happened to Your Data.  We’re going to cover how to find out who made schema changes, who deleted/truncated tables, and how to get the data back without time-consuming full restores.  I’ll be talking through some of the native SQL Server tools to do it, and Jason will be showing off the Quest tools that make the job easier.

Performance Dashboard Reports

These say Performance in the name, so it would sound like they’re not the right answer to this problem, but it turns out there’s a great report in there to address this very issue.  The Schema Changes History report shows what logins made schema changes in each database, and when the change was made.  Here’s an example:

SQL Server Performance Dashboard

SQL Server Performance Dashboard

These reports run off the default server-side trace that runs all the time in SQL Server 2005 and 2008, so there’s no additional performance impact in order to capture this information.  These reports are included with Microsoft SQL Server 2008, and for 2005, they’re a separate download - download the Performance Dashboard Reports.

These reports have been part of the solution in all of my recent webcasts.  I’m a big believer that every DBA needs to have these installed and play around with them because they’re so useful.  I was just giving career advice to a DBA yesterday: he specialized in writing reports, and I said if there’s one type of report to produce, it’s RDLC reports that integrate with SQL Server Management Studio.

That’s a great start - it does tell us who did it and a little bit about what they did - but it only works with SQL 2005 & 2008, and it doesn’t give us exactly what their statement was, and it doesn’t give us anywhere near enough to roll back their devious work.  We need more information, so let’s get the toolbox out of our Hummers and check out our next tool.

Database-Wide DDL Triggers

SQL Server 2005 introduced DDL triggers that can be fired off whenever someone runs Data Definition Language code like altering a table, adding an index, or dropping a view.

People have written DDL triggers that log schema changes to a table - here’s one example of auditing DDL statements in a table, and here’s another.  I’ve used some of this code myself to track schema changes, and I do love the results:

DDL Trigger Results

DDL Trigger Results

I get a nice table with who the guilty culprit is and I get their exact SQL statement.  That’s a step in the right direction, because I can print it out and take it with me into the interrogation room.  (Every DBA has an interrogation room, right?)

That gets us our confession and our guilty verdict, but it doesn’t get us back to how things used to be.  For that, you’ll need to tune into our next episode - I mean, webcast!

Technorati Tags: , , ,

Does SQL Server support PCI Compliance Standards features including periodic changing of keys, destruction of old keys, split knowledge and establishment of dual control of keys, and prevention of unauthorized substitution of keys?

Filed under: Administration, Katmai, Product, Security — Ari Weil at 9:11 am on Thursday, May 29, 2008

SQL Server 2008 has the encryption key management feature’s you’re looking for…

SQL Server 2008 Extensible Key Management enables the encryption keys that protect the database files to be stored in an off-box device such as a smartcard, USB device, or EKM/HSM module. This also enables data protection from database administrators (except members of the sysadmin group). Data can be encrypted by using encryption keys that only the database user has access to on the external EKM/HSM module.

Extensible Key Management also provides the following benefits:

* Additional authorization check (enabling separation of duties).
* Higher performance for hardware-based encryption/decryption.
* External encryption key generation.
* External encryption key storage (physical separation of data and keys).
* Encryption key retrieval.
* External encryption key retention (enables encryption key rotation).
* Easier encryption key recovery.
* Manageable encryption key distribution.
* Secure encryption key disposal..

See the full article Understanding Extensible Key Management for details.

How can I find out what roles a user belongs to and what objects they have permissions to?

Filed under: Security — KKline at 11:30 pm on Tuesday, November 13, 2007

Q: I need a query that will tell me all objects that a user account has access to in each database on the server. How can I find out what roles a user belongs to and what objects they have permissions to?

Kevin Kline says: You need to get familiar with the free SQL Server Script Library that is available at http://www.microsoft.com/technet/scriptcenter/scripts/sql/sql2005/default.mspx?mfr=true  

However, since you specifically are looking for permission information be sure to check www.sqlsecurity.com for great (and free) scripts related to all things security.

Technorati Tags: , , ,

In Development database, I have granted CREATE STORED PROC permission to all of our Developers. When they create SP, I compile their SPs as dbo. Then I grant Exec permission so that Developers can execute each other’s SP. This saves me from granting permission to each of the underlying objects–table, view, etc. through ownership chaining. It adds extra step for developers who have to come to me to compile their SPs, otherwise they run into broken ownership chain issue. If I make them database owner to the database, I fear that they may accidentally delete each other’s SPs. How do I solve this problem?

Filed under: Programming, Security — Ari Weil at 5:18 am on Wednesday, November 7, 2007

You should take advantage of security groups if you want to keep your current arrangement; add the developers to a single group and simply maintain the group’s authorities.

Still, I should think Database Snapshots are perfect for your situation. A snapshot is a static, read-only view of a database. You can have the developers create their procedures on the snapshot, evaluate the code, then create it on the source database. The developers can have full access to the snapshot database, while you maintain restricted permissions on the source (real) database. Read more <a href=”http://msdn2.microsoft.com/en-us/library/ms190467.aspx”>here</a>.

How I can handle SQL injection attackcs using a query??

Filed under: Programming, Security, Transact-SQL (T-SQL) — KKline at 3:51 pm on Friday, August 31, 2007

Q:   How I can handle SQL injection in all over application by using query??

Kevin Kline says:   It’s funny that you mention this since Microsoft UK just had a very public SQL Injection attack on their website. It’s reported on TechWorld here.

In essence, a SQL Injection attack is where a programmer has written a web page that exposes a SQL query to the internet. For example, you might write a query that allows the end user of a web page to enter the name of product that they want to find on the web site. However, the web site is now vulnerable to attack because the programmer placed no string checking onto the values returned by the web page, which some malicious person could, instead of putting the name of product into the open field, substitute something like ‘DELETE FROM products’.

SQL Injections is a broad and complex topic though. So you’d best read what the experts have written. I like what NGS Software puts out, such as this white paper.

I also really like Chip Jones’ website called SQL Security.com, which has extensive information on SQL Injection attacks and defenses. It also has a really good utility available for free called LOCKDOWN.SQL.

Technorati Tags:
, , , , , ,

I have forgotten the SA password to my SQL Server instance. Do you have any idea how can i retrieve the SA password? I need this very urgent!!!!

Filed under: I'm a Newbie, Security — Jason at 8:42 am on Friday, August 24, 2007

Jason Hall says:  There is no Microsoft supported method for retrieving a password from SQL Server. Your best bet is to log in with some other administrator account (windows authentication perhaps using the local administrator account on the SQL machine) and reset the sa password using Management Studio. 

How can I password protect my database?

Filed under: SQL Server 2005, Security — Bryan Oliver at 9:11 pm on Monday, August 20, 2007

Q:  How can I password protect my database?

Bryan Oliver says:  In SQL Server 2000 you can encyrpt your stored procedures.

If it is data, particular that you want to protect take a look at this article on SQL Server central

For SQL Server 2005 take a look at this article on Database Journal.com

Hope this helps!

Technorati Tags:
, , , ,

How to to design an access rights table which will store security related information?

Filed under: Database Design, SQL Server 2005, Security — Bryan Oliver at 5:30 pm on Tuesday, August 14, 2007

Q:  I need to design an access rights table which will store all security related information. My aim is that every user has access to different sections in the web page. For eg User A can see Menu A while user B can see Menu B. or User C can add an object C while User D can delete an object D. I have a list of activities/processes on which I need to give access information. Currently this is stored as a process bit (a 2 to power n value). But this has limitations since the SQL Server data type would not allow me beyond say 50 processes (since it would be 2 to the power 50 which is a huge no) Can you please suggest me a simple way of doing this?

Bryan Oliver says:  You would need a user table that tells u what security level they are.

Than a security object table that has the object.

Than a security object level table that links the object to all the levels that are available, like displayed, read, write, delete and so on.

You will need to use more that one table to overcome your 2 to the power of 50 issue.

Technorati Tags:
, ,

Next Page »