Our customer has a problem with database information in plaintext within a server.xml or context.xml file on the Tomcat server. I've looked at several sites like OWASP and it seems like there's no obvious solution. I've also seen things like this wordpress blog which describe implementing a custom Tomcat extension to do this. There must exist some standard implementation(s) already without having to roll your own. Does anyone have experience with such a solution?
The password is currently stored in plaintext in the config file. The alternative, which is often used in, say, DES-encrypted SSL private keys, is to use a symmetric algorithm to encrypt the sensitive data.
This would be no more secure than just storing the password in plaintext in the .xml file. The service would be configured with the encryption key of the encrypted secret (unless you require someone to be at the keyboard to enter the password every time the service starts), which can be used by an attacker to get at the encrypted data. This provides a layer of obscurity, but not a layer of security.
Encrypting the password is marginally better than having it plan text. CVS does a character replacement of its plain text password to protect against accidental disclosure when browsing files. The file containing the password needs to be properly secured no matter what the form.
A standard encryption method is marginally better than a plain-text password. This is a well recognized security risk. A simple method such as CVS uses does protect against accidental disclosure to administrators who have access to the file.
MySQL allows restrictions based on the originating host which I would implement if that is your database. Database servers of any sort should have limited access.
Once someone gains access to your host, the battle is pretty well lost.