Protect local Mysql DB access

This is a discussion on Protect local Mysql DB access within the PHP Language forums, part of the PHP Programming Forums category; Hi, I just password-protected an intranet site by including a password authentication script in each page of a private ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-02-2004
Flier_75
 
Posts: n/a
Default Protect local Mysql DB access

Hi,

I just password-protected an intranet site by including a password
authentication script in each page of a private section. The script
checks the login against the mySQL database. Appropriate file
permissions have been set up on the private directory.

My concern is now about protecting the Mysql password. Let's assume I
use Apache to protect the access to this password (<files></files> or
SetEnv in httpd.conf).

In my intranet directory, I have a public folder where I let users put
their html/php files to build their own pages.

How can I prevent a user from creating a php file like this :

$conn = mysql_connect($_SERVER['SQL_DB'],$_SERVER['SQL_USER'],$_SERVER['SQL_PASS'])
or die(mysql_error());

$sql = 'update user set private_access= '1' where username =
'myself'';
$result = mysql_query($sql) or die(mysql_error());

In that way, without knowing the Mysql pwd, any user can finally have
access to the private section.

Can anyone tell me how I can manage this ?

Thanks !
Reply With Quote
  #2 (permalink)  
Old 06-02-2004
Tim Van Wassenhove
 
Posts: n/a
Default Re: Protect local Mysql DB access

In article <b7dced84.0406020751.16bdeebf@posting.google.com >, Flier_75 wrote:
> How can I prevent a user from creating a php file like this :
>
> $conn = mysql_connect($_SERVER['SQL_DB'],$_SERVER['SQL_USER'],$_SERVER['SQL_PASS'])
> or die(mysql_error());
>
> $sql = 'update user set private_access= '1' where username =
> 'myself'';
> $result = mysql_query($sql) or die(mysql_error());
>
> In that way, without knowing the Mysql pwd, any user can finally have
> access to the private section.


Read the MySQL manual on access rights.
Add an account that has only rights on the columns/tables/databases it
should have (Thus excluding thet private_access column in this case).

--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php>
Reply With Quote
  #3 (permalink)  
Old 06-02-2004
Flier_75
 
Posts: n/a
Default Re: Protect local Mysql DB access

Tim, thanks but if I use an account that for instance doesn't have
access to the columns "private_access" and "user_password", then how
could I do if I want the users be able to change their password from
my php pages ?
These php pages use one and only one $_SERVER['SQL_USER'] account.

Tim Van Wassenhove <euki@pi.be> wrote in message news:<2i6fitFj5dtnU1@uni-berlin.de>...
> In article <b7dced84.0406020751.16bdeebf@posting.google.com >, Flier_75 wrote:
> > How can I prevent a user from creating a php file like this :
> >
> > $conn = mysql_connect($_SERVER['SQL_DB'],$_SERVER['SQL_USER'],$_SERVER['SQL_PASS'])
> > or die(mysql_error());
> >
> > $sql = 'update user set private_access= '1' where username =
> > 'myself'';
> > $result = mysql_query($sql) or die(mysql_error());
> >
> > In that way, without knowing the Mysql pwd, any user can finally have
> > access to the private section.

>
> Read the MySQL manual on access rights.
> Add an account that has only rights on the columns/tables/databases it
> should have (Thus excluding thet private_access column in this case).

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:47 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0