views:

201

answers:

3

For a database that is shipped with a remotely deployed product, are there any drawbacks to encrypting all code objects (procs, functions, views) via the WITH ENCRYPTION clause in MS SQL Server 2005 and 2008?

The advantages are a deterrent to "custom" changes in the field that solve one need while creating many more. The goal is not to protect IP or data, but to help prevent unauthorized code changes when the rights to alter objects cannot be managed (the security is out of the developers hands, but the responsibility to fix issues caused by others is).

What new problems could be caused by taking this approach?

+2  A: 

Microsoft created this feature specifically for this purpose. The only drawback I can see is that the protection is weak; it can be circumvented by publically available scripts, and SQL Profiler can be used to view the clear text of the decrypted procedures. But it should still act as an effective deterrent.

Robert Harvey
I am certain I read some docs about Profiler and encrypted objects, but cannot locate them now. Did you use a DAC when profiling to make the details visible?
MattK
Robert Harvey
I actually haven't done it myself. Are your users sophisticated enough (or masochistic enough) to figure it out?
Robert Harvey
Also see here: http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci841704_mem1,00.html
Robert Harvey
Sophisticated/Masochistic does not quite describe the problem, and it is often not the end users. Sometime people closer to the shop will go out of their way to _not_ ask for help in deploying the correct solution to a problem.
MattK
I don't think Profiler shows the decrypted text. This was a problem we had when debugging. We had to unencrypt everything to get a better experience in Profiler.
Matt Spradley
A: 

We implemented encryption in an enterprise product that we deployed to 200+ sites for the reasons you indicated and to deter reverse engineering.

In our case, it was more trouble than it was worth. Our clients never really changed anything and it made it difficult for us to debug issues in the field. Profiler does not give you the detail needed when everything is encrypted. We would often have to load an unencrypted version of our SPROCs etc. to debug issues.

Also, it makes it harder to varify your schema is consistant with the version you are expecting. Most differencing tools can't diff encrypted objects.

Matt Spradley
A: 

You are down the wrong path. WITH ENCRYPTION is an obsolete option from the SQL 2000 days. The ways around it are well known and can be discovered by anyone with minimal google search skills. The proper way is to use code signing. Best way is to create a certificate, sign the procedures, then drop the private key. This way nobody, not even you, can change code afterward without destroying the signatures. This does not prevent anybody from modifying the procedures, but once modified they destroy the signature seal and the tampering is evident. You can take it one step further and make sure the procedures in themselves have no authority to execute their purpose (ie. cannot read the tables the try to access) but the authority is derived from their signatures (the certificate used to sign them is granted the needed rights). This way if they tamper with the code not only they destroy the seal, they also cause the system to halt. Explaining the consequences of these actions is usually a strong enough deterrent.

Remus Rusanu
Thanks for the typical "Let me Google that for you" response by answering a question I did not ask. The encryption strength nor the ability to detect changes is not the issue. The question was about potential problems caused by code encryption, in an environment where we do not have any path to apply consequences for unauthorized changes.
MattK
In a public forum an answer is read by many. If is of no use to you, I could not care less. And no, I don't have to google for features I was so closely involved with...
Remus Rusanu