Support » Installing WordPress » Is wp-config a security problem?

  • I was just doing a tutorial on Flash/PHP integration (another great one by webmonkey if anyone is interested At the end, he suggests insulating your mysql_pconnect request with a require/include. I did this for my Flash scripts, but wp-config.php doesn’t use mysql_pconnect. I have multiple WP installs on the same server. Is there anything I should do to protect the integrity of my server?

    Thanks again,

Viewing 15 replies - 1 through 15 (of 15 total)
  • Mark (podz)


    Support Maven

    For wp-config.php, you are fine.
    Nearly a million 1.5 downloads
    Over 350,000 2.0 downloads

    If there was anything wrong there, we’d all know by now 🙂

    I figured but thought I’d check. Thanks.

    So how is it that this has your l/p in plain text on a webserver and nobody cares, but the webmonkey guy has you post your l/p locally as an include? Is it possible to get a raw PHP file off of a webserver (w/o FTP of course)?


    Is it possible to get a raw PHP file off of a webserver (w/o FTP of course)?

    Typically not. Scripts exist which can output the source of PHP files, but they need server-side (local) access to those files to do so.

    The “webmonkey guy” does describe a more secure method of handling ones MySQL login details, but its not one your average WordPress user will be able to *easily* implement, if at all. For those who can…well, no amount of security is too much.

    I’m wondering, couldn’t wp-config.php be placed in a directory above the www? Obviously you’d have to modify the calls to wp-config, how many files call it directly though? (I’d actually like to know, as I have no idea!)

    I’m wondering, couldn’t wp-config.php be placed in a directory above the www?

    As my host does not provide access to anything above the web directories, the answer for me is: No. But for those who do, I think adding an .inc file for just the MySQL login info and including that in wp-config.php would be less problematic.

    Just to keep somebody from making a really bad mistake here:

    Don’t move your MySQL/db info to an .inc file, place that in a web-accessible directory, and include it in your wp-config.php (or anything else). Such a step is most definitely NOT secure, at least on a server which does not protect .inc files.

    Yes, .inc can be bad! I just tested out the suggestions above, placed a file, say db.php in a directory that is above the www root (ie: not web accessible) and just used a require_once in wp-config.php, and it works perfectly well.

    I’m not sure if this makes any difference in terms of security, I’m sure if one is determined enough to get in, in the end they will. In any case, the feeling of being slightly more secure could be good.

    Thanks Kafkaesqui!

    I wonder if that would be a way to make WordPress work with subdomains (I realize there’s mu, but my host doesn’t use Apache). If you named all your includes you ought to be able to require('localpath/'.$subdomain.'.inc'); Then, if you had a script that pulled $subdomain from the location bar, you could run multiple copies of WP from one central installation. Of course, the themes and all resources would be affected globally if changed by one user, and you’d still need multiple databases, but it is an interesting pondery nonetheless. . .

    Those of you who are concerned about security are 100% right.
    Answering to security concerns by providing stats on the number of download is 100% useless.

    Regarding the issue we are talking here, you should read the following announcement if you are running WP <=2.0.5

    You might also want to read more about sql injection.
    If you are a developer (let says a WP developer..), I would highly recommend you to use AT LEAST bind variables in all your SQL scripts and to avoid any string concatenation in your SQL statements, among others things.

    I haven’t read any single line of code of WP, but the exploit is related to SQL injection.

    The thing to remember here, is that although the wp-config.php file is in the web root it cannot be looked at (as it is a php file)
    The only way to get to it is with FTP, or an attack that somehow compromises the server.
    By moving the file outside the web root doesn’t really help, because once someone has access to your server, either through FTP or an attack, they can still see the file outside the web root.
    No amount of obfuscation will stop someone who has access to the server getting at your details.

    Make sure though, that the password you use for your database is NOTHING like any other passwords that you use, as if this is compromised then there is a good chance the hacker can then compromise your other accounts as well.
    Ideally ALL your passwords should be different. But in the real world this cannot really be done (unless you are super-human).
    Thing is, this is a potentially visible, clear text password so make sure it’s not something you would normally use for anything else.

    the mighty G search tool has come up with code-search which will dig out your php file codes and show it to the www

    so even if you see nothing while pointing to the file the big G will dig them out for you with their codesearch, secure your cofig file now boys and girls.




    what you are implying is absolute crap, kenl77, and I challenge you to show a single instance where a wp-config.php that is currently being used for a live site is being displayed in plain text via Google.

    Excuse me, kenl77?

    You’ve placed this warning in at least two places here, but you haven’t tied it in with what has already been posted. Can you please explain what “the mighty G search tool” is?

    I kind of imagine you’re referring to Google, but I guess I must not be “in the loop” to know for sure.




    He’s referring to Google’s code search tool, and he’s terribly misinformed.

    There were EARLY instances where Google was picking up wp-configs that were being stored inside backups.

    To that end, backups should not be stored on the server anyway — mainly because it defeats the purpose of having a backup in the first place, but also because of obvious security issues. Archives are downloadable after all. It’s also worth noting that the backup plugin uses a random directory name.

    The plain fact is that a wp-config.php is NOT visible to a browser OR to Google’s code search, as long as its NOT renamed or stored inside an archive, etc.. In other words, Google cant read my wp-config.php and neither can he.

    “Is it possible to get a raw PHP file off of a webserver (w/o FTP of course)?”

    If the server somehow screws up such that instead of processing PHP files, it decides to show them as plain text, then you are in trouble. How likely is this? Not sure…

    Why take a chance though if you know how to move your username/password into a file outside your www root?

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Is wp-config a security problem?’ is closed to new replies.