Hi,
I was wondering if it’s safe to have config.inc.php stored as a clear text file. Is it possible to encrypt the whole file or at least the database connection info?
Anyway, is it really safe to have this file stored as clear text? Is it enough to have it as "read only" ?
Your help will be appreciated.
Thanks.
Mc
-
☆ A M B ☆
- 24,524 Posts
Well, in the three years (or more? I’m losing track of time here) the only time it’s been bothered is when somebody left it world-writable.
-
☆ A M B ☆
- 24,524 Posts
There are others who should be better able to address that than I; I’m an "if it works don’t break it" kind of person
To play devil’s advocate to your question --
In its default location/permissions, if someone can remotely access that file, you have MUCH bigger issues than someone accessing your CMS at that point. On top of which, encrypting the file is not a trivial manner, because the question then becomes, where and how do you securely store the decryption key so that it’s safer than the plain text file to start with?
I do think there a valid issue here though. Maybe it would make sense to store the passwords in an crypt() format with the key being elsewhere. That wouldn’t prevent a determined hacker, but it’d certainly avoid the person casually looking through files on your web server.
an alternative would be to store your db credentials in another file, store it outside the web root, and then include it in the config file.
one problem with using encryption is that decryption can be quite cpu intensive depending on the algorithm used, so unless there’s a vulnerability (obviously this is what you’re trying to defend against), you’re just wasting cpu cycles. this can have a big impact if the site is under high load.
storing the credentials outside the web root is a compromise, adding a bit of extra security without the overhead of decryption.
-
☆ A M B ☆
- 24,524 Posts
But as vbrilon mentioned, if you’ve got somebody wandering around in your files, you’ve got much bigger problems. As long as you don’t have the config file world-readable, they can’t even read it unless they have your login or root. I have my files set to be owner and group read/write, and assigned the Apache user to my group. Now nobody can get access as the Apache user; it doesn’t really have a login and certainly has no shell. So if somebody gets in as me or as root, the my server is dead meat anyway. If you’re using suexec, you don’t even need to have the Apache user in the equation.
Just a point here on ’shared hosting providers’, any admin of these servers can see anybody’s config file if they want to, they can also completely trash your MYSQL database if they want to and delete all your files, encryption wont help here, you just have to trust them<paranoia>whoever they are!</paranoia>
Use MODx, or the cat gets it!