views:

1183

answers:

2

I'm developing an intranet application (C#) that uses some data (local to the web server) that we'd like to keep private. This data is encrypted (AES) using a legacy data repository. We can't totally prevent physical access to the machine.

Clearly, we're never going to have perfect security here. However, we want to make it as hard as possible for anyone to gain unauthorized access to the data.

The question is how best to store the key. Encrypting it based on some machine specific ID is an option, but that information would be readily available to anyone running a diagnostic tool on the machine.

Encoding it in the application is an option (it's a one off application). However, .NET assemblies are pretty easy to decompile. So, would it be best to obfuscate it, use an encryption launcher, compile it?

Or is there an option I'm missing?

Just so we're clear, I know it's pretty much a lost cause if someone is determined, but we're looking to make it as hard as possible within the constraints.

+3  A: 

Encryption is built into the .NET configuration system. You can encrypt chunks of your app/web.config file, including where you store your private key.

http://www.dotnetprofessional.com/blog/post/2008/03/03/Encrypt-sections-of-WebConfig-or-AppConfig.aspx

FlySwat
This is how I've done it in the past.
Chuck Conway
If you have access to the machine, can't you just write an app that references the encrypted sections and it'll hand you the plaintext? I thought this was only secure if you didn't have access to the machine.
@yahoo: you are correct.
Chris Lively
yahoo, nothing is secure once you have physical access.
FlySwat
A: 

If somebody can just attach a debugger to your program, there is absolutely nothing you can do. They won't have to figure out your config, disassemble your app, etc. All they have to do is run the app - watch it use the key - bingo.

Obfuscation is of no help under those conditions.

The best defense is to use hardware to protect the key - which will do the crypto but not give out the key itself (and is sometimes hardened against attacks such as probing the wires, exposing the memory to low temperatures/radiation/other novel stuff). IBM do some appropriate stuff (google IBM-4764) but it's not cheap.

Alun Harford