Sensitive Data Storage – Best Practices

datastorage

I recently started working on a personal project where I was connecting to a database using Java. This got me thinking. I have to provide the login information for a database account on the DB server in order to access the database. But if I hard code it in then it would be possible for someone to decompile the program and extract that login info. If I store it in an external setup file then the same problem exists only it would be even easier for them to get it. I could encrypt the data before storing it in either place but it seems like that's not really a fail safe either and I'm no encryption expert by any means. So what are some best practices for storing sensitive setup data for a program?

Best Answer

Several options here:

  • Run the Java program under a domain user which is granted access to the database (or, alternatively, store the password information in a file which is only accessible by the user that is running your program).

  • use a key store, with restrictions to both the user and software which will be using the key (such as what Mac OS X provides)

  • use a standard encryption solution, with an interface which will require input of the encryption password on program startup (so the admin starting up the program knows the password, only)

  • require that the uid/password for the database be entered on program startup

Related Topic