datanut Posted March 28, 2012 Share Posted March 28, 2012 I've been trying to find a good, up-to-date source on how to secure the authentication credentials for my db connection. I've done some PHP coding and would like to learn more. There's plenty information available, but I often find books inevitably have typos in the code. Also most of the online tutorials are either at least several years old or deal more with user login security. User authentication is one thing, but what are the best ways to secure the connection to the database itself? Obviously your basic newbie method of unencrypted host, username, password, and database stored in a connectvar file is just open invitation--or maybe not since it doesn't present a challenge to a hacker. Some say to encrypt the credentials with something like MD5 and store them in .htaccess. Other sources say not to use MD5. Any advice on where to find some good resources on this? Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/259868-db-connection-advice/ Share on other sites More sharing options...
Muddy_Funster Posted March 28, 2012 Share Posted March 28, 2012 depends on your scenario, is your webserver also your db server or do you create a remote connection? Quote Link to comment https://forums.phpfreaks.com/topic/259868-db-connection-advice/#findComment-1331847 Share on other sites More sharing options...
datanut Posted March 28, 2012 Author Share Posted March 28, 2012 Right now, I'm hosted at godaddy with the economy linux setup (rather liquidweb but on the cheap right now), i.e. sharing server space with who knows what. With that said, looking at one of the warnings in phpMyAdmin about enabling statistics, the web server and MySQL server are separate. Quote Link to comment https://forums.phpfreaks.com/topic/259868-db-connection-advice/#findComment-1331895 Share on other sites More sharing options...
scootstah Posted March 28, 2012 Share Posted March 28, 2012 Storing the credentials in a PHP file is usually perfectly fine. An attacker would have to gain entry to your filesystem to retrieve the database credentials. The only thing they can do with the database credentials is access your database, right? So even if you encrypt them, if an attacker has access to the filesystem he can just upload his own script and tap into your existing connection anyway; thereby having all the access to the database that he wants. EDIT: So put simply, if an attacker gains access to your filesystem you are screwed either way. Quote Link to comment https://forums.phpfreaks.com/topic/259868-db-connection-advice/#findComment-1331899 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.