Database Security Not So Secure Database Security Not So Secure database database

Database Security Not So Secure


There is an old saying "Encryption is easy, key management is hard". And that very much applies here.

If you need to store data in an encrypted format (you frequently don't because you only need to hash the data not encrypt it), you do not want the encryption key to be stored in the database. You want the key to be accessible when your applications need to decrypt the data but you don't want people like the DBA that has access to all the encrypted data to be able to get the key. You want to make sure that the key is backed up so that you can recover the data but you don't want those backups to comingle with your database backups. Key management, therefore, becomes a very thorny problem to solve.

In the vast majority of cases, you want to purchase some third-party key management solution that can deal with these contradictions. Just like you don't want to implement encryption algorithms on your own, you don't want to do key management on your own. The folks that attempt to solve key management on their own generally do not succeed.


A better option would be to use certificates and this can easily be done in most RDBMS.


The best option regarding passwords is to hash them. This is a one way hash, and is not decrypted. Basically, when a user logs in, you hash their input password, and compare the hash against the one stored in your db for a match - and a successful login.

Regarding payment information, you will need a random generated private key. Depending on the system and implementation this can be stored a number of different ways.You can store this in a config file, encrypted using an RSA container for example so it is not readable.There are other solutions as well.

You can also encrypted db connection strings and the like with the RSA container method above to help prevent anybody actually seeing you db username password your application will use to access the db.