Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
Ah, well, that means encrypting the password text is not really a solution even if it is what they "think" they want. Are there better solutions to securing the connection information? – Greymeister Mar 10 '11 at 16:25
@Graymeister Secure the system that the service runs on, and secure the file that contains the password so that only the service's user can read it. If the service itself is compromised, the database connection is compromised, password or not. – Shane Madden Mar 10 '11 at 18:36

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.

share|improve this answer
Thanks for the input – Greymeister Mar 10 '11 at 19:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.