Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

I manage a php app whose key variables (such as database server addresses, DB user names and passwords, etc) change depending on their environment (Dev, QA, Production, etc.).

In order to simplify deployment, I have started moving some environment dependent variables out of .ini configuration files that are part of the code base and into the Ubuntu apache2 /etc/apache2/envvars file.

I have not yet moved passwords to this file, but am considering it. The question is this: if all it takes is a phpinfo.php file to expose those DB passwords in the "Environment" section is it safer to just leave DB passwords where they are, in the .ini config files located outside the web root?

share|improve this question

migrated from serverfault.com Dec 3 '11 at 1:16

This question came from our site for professional system and network administrators.

2 Answers 2

I completely agree with your opinion that it is no wise idea to have phpinfo() dump your DB passwords. An ini file seems to be a little bit better, your application can retrieve the passwords when needed. With current frameworks like Symfony this is the way to go. If you restrict access to the production machines to administrators in charge you have a limited circle of persons that could access the configuration files. Of course the ini files should not get stored in a public repository. The drawback is that the application itself, your webserver user must have access to the file and thus any PHP script could read and dump it.

This raises the question of wether you are willing to make huge efforts to improve security.

In the Java EE world you can apply the following concept. You deploy an enterprise application to an application server like GlassFish or JBoss. In the concrete JDBC configuration you set a placeholder for the password. The actual password can be stored within an encrypted password file for which the administrator has to enter a password upon startup of the server. Naturally this prevents a fully automated server startup. I personally cannot assure you that this is 100% bullet proof but it makes it more difficult for an attacker.

Another possibility is to "outsource" your passwords. You could use a password service (google for "Cyber-Ark", I think they have an API/SDK to connect own applications to their password vault) tool that stores passwords and controls access. Every time your application needs a password it must be retrieved from the service. Of course, someone who gains access to the API and the login data to the password service could request passwords, too. But with a separated service you have at least the option of logging access to have an audit trail available. Separation of duties: if the password service has another administrator it gets hard for one person to do things that are not allowed, or at least there's a chance to track these things.

share|improve this answer

While dealing with password files, we must see that only those users can access the password details who 'need to know' that. In your case, do people having access to code tree i.e. the .ini file need to know the DB details and the passwords because they might not have access to the environment section. If they have access to the code tree as well as the environment, I think you are right and you can leave those details in the .ini file but make sure it is outside of the webcontent directory.

Right now I can think of this only.

All - Please feel free to correct me or add anything which I missed.

share|improve this answer

Your Answer

 
discard

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.