Go Back   HostGator Peer Support Forums > Public Forums > Pre-Sales Questions

Notices

Reply
 
Thread Tools
  #1  
Old 05-20-2007, 01:30 AM
dbstraight dbstraight is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 4
Default MySQL login security on shared hosting

I have one question which will either be a deal-maker or deal-breaker:

Can I make it impossible to access my MySQL login credentials in my PHP scripts?

If they are in plain text or an included file, they are accessible.

Since modifying httpd.conf is impossible, it is impossible to use the preferred method on security sites of setting the username and password as environment variables and referring to them with $_SESSION.

With that in mind, can it be done? If not, no matter how attractive this shared hosting looks, I won't use it. If it can be done, I'm almost ready to sign up.
Reply With Quote
  #2  
Old 05-20-2007, 03:19 AM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: MySQL login security on shared hosting

Quote:
Originally Posted by dbstraight View Post
If they are in plain text or an included file, they are accessible.
If they're being parsed by the php processor, how are they accessible?
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #3  
Old 05-20-2007, 08:01 AM
kmaw's Avatar
kmaw kmaw is offline
Emperor Croc
 
Join Date: Mar 2005
Location: Ontario, Canada
Posts: 1,921
Default Re: MySQL login security on shared hosting

Talk about re-inventing the wheel...
Reply With Quote
  #4  
Old 05-20-2007, 09:09 AM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,073
Default Re: MySQL login security on shared hosting

Quote:
Originally Posted by dbstraight View Post
With that in mind, can it be done? If not, no matter how attractive this shared hosting looks, I won't use it. If it can be done, I'm almost ready to sign up.
Yea, that is a deal breaker. Since changes to httpd.conf are system wide, I can't see how that would be safer. When you use strange/bizarre configurations, you can't really be in the shared environment.
__________________
Six stages of Dedi Ownership

Fashionable broken link
image included
Reply With Quote
  #5  
Old 05-20-2007, 01:09 PM
steve_a steve_a is offline
Baby Croc
 
Join Date: May 2007
Posts: 61
Default Re: MySQL login security on shared hosting

You have directories that are not public to the web. You can put a file there and fread it.
I wouldn't say env vars are more secure. A php file is parsed unless it doesn't end in .php.
Reply With Quote
  #6  
Old 05-21-2007, 12:56 AM
dbstraight dbstraight is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 4
Default Re: MySQL login security on shared hosting

A PHP file is parsed under most circumstances, yes. If, however, someone on the same server as me used a PHP script to access one of my PHP scripts, they could get the source code. If the login credentials are in plain text, they're exposed. If the PHP script includes another file, they can just use a PHP script to get that file. Anything my PHP scripts can read can be read by other PHP scripts running on the same server with the same permissions.
Reply With Quote
  #7  
Old 05-21-2007, 01:05 AM
charlesgan's Avatar
charlesgan charlesgan is offline
Swamp Croc
 
Join Date: Mar 2007
Location: http://www.hostgatorreview.org/
Posts: 372
Default Re: MySQL login security on shared hosting

definately you not going to put the login information in the .txt extension file. ANyone can just browse it and get it.

rename the file to "myconfig.php" for example, with .php.
and the setting is all within the <php>... thus no one can view it.
meaning you assign the setting to variable and store it, so at your calling page, you can use that value.
__________________
Charles Gan
Hostgatorreview.org
Reply With Quote
  #8  
Old 05-21-2007, 01:11 AM
dbstraight dbstraight is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 4
Default Re: MySQL login security on shared hosting

But someone CAN read it, that's the point. All they have to do is be on the same server and set up a PHP script to file_get_contents() of my PHP files, and they'll get the source code.

Suppose the web server runs as "nobody" on Linux. In order for PHP to access my file with my database credentials, the file has to be readable by "nobody" because PHP will run as "nobody." The problem is that EVERYONE'S scripts will run as "nobody," so everyone's scripts will have access to my file.

Last edited by dbstraight; 05-21-2007 at 01:23 AM.
Reply With Quote
  #9  
Old 05-21-2007, 04:49 AM
gtgeorge's Avatar
gtgeorge gtgeorge is offline
Emperor Croc
 
Join Date: Mar 2005
Posts: 2,223
Default Re: MySQL login security on shared hosting

Maybe you are asking the wrong questions. Perhaps you should ask about open_base_dir and phpsuexec....
__________________
best regards,
George
Reply With Quote
  #10  
Old 05-21-2007, 05:19 AM
quietFinn's Avatar
quietFinn quietFinn is offline
Veteran Croc
 
Join Date: Feb 2005
Posts: 3,475
Default Re: MySQL login security on shared hosting

Quote:
Originally Posted by dbstraight View Post
Suppose the web server runs as "nobody" on Linux. In order for PHP to access my file with my database credentials, the file has to be readable by "nobody" because PHP will run as "nobody." The problem is that EVERYONE'S scripts will run as "nobody," so everyone's scripts will have access to my file.

No.
HostGator servers run PHPSuExec, which means that PHP is running using the account's username. This also means that one user's PHP scripts can NOT read other user's PHP (or any other) files.
__________________
quietFinn - netFinn Finland
"Be who you are and say what you feel because those who mind don't matter and those who matter don't mind." - Dr. Seuss
Reply With Quote
  #11  
Old 05-21-2007, 07:24 AM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,073
Default Re: MySQL login security on shared hosting

Quote:
Originally Posted by dbstraight View Post
But someone CAN read it, that's the point. All they have to do is be on the same server and set up a PHP script to file_get_contents() of my PHP files, and they'll get the source code.
I'm sure that is true on systems without any security, but I think you will find that most good hosts are running PHPSuExec.

As has been pointed out, you really need to ask the right questions instead of trying to get hosting companies to jump through hoops to meet your requirements, when they actually already meet and exceed your requirements.
__________________
Six stages of Dedi Ownership

Fashionable broken link
image included
Reply With Quote
  #12  
Old 05-21-2007, 02:18 PM
dbstraight dbstraight is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 4
Default Re: MySQL login security on shared hosting

My question here was "What can be done?" I don't see how that could be the wrong question.

Sadly, none of the sites I've read on PHP security, not even the PHP security consortium, bother mentioning this fact.

I guess it really is my fault for not looking into it more, but I've had an extremely difficult time finding good information. I was unaware of such protections. Thanks for answering my questions.
Reply With Quote
  #13  
Old 05-21-2007, 03:54 PM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,073
Default Re: MySQL login security on shared hosting

Quote:
Originally Posted by dbstraight View Post
My question here was "What can be done?" I don't see how that could be the wrong question.

Its not wrong to ask the question, it was the way you asked it.


You will find it difficult to find the information you are looking for online, there isn't really a good place to go to get the 'real' information.

Shared hosting is plenty safe. In fact, the problems you are worried about are NOT the problems that you need to be worried about.
__________________
Six stages of Dedi Ownership

Fashionable broken link
image included
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 01:41 AM.