Secure MySQL connection authentication?

This is a discussion on Secure MySQL connection authentication? within the Database Discussions forums in Database and Unix Discussions category; currently we store user/pass in a plain php file, but we want to have a better method to protect the MySQL login authentication by hiding the real user name & password are there any suggested solution? thanks....

Go Back   Database Forum > Database and Unix Discussions > Database Discussions

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 01-04-2007, 10:35 PM
Default Secure MySQL connection authentication?

currently we store user/pass in a plain php file, but we want to have a
better method to protect the MySQL login authentication by hiding the
real user name & password

are there any suggested solution?

thanks.

Reply With Quote
  #2  
Old 01-05-2007, 05:11 AM
Default Re: Secure MySQL connection authentication?


howa wrote:

> currently we store user/pass in a plain php file, but we want to have a
> better method to protect the MySQL login authentication by hiding the
> real user name & password


Hiding it from whom? By putting it in a plain php file, you are hiding
it from all except those who can access the php file. So who else do
you wish to hide it from. The solution depends on this.

Reply With Quote
  #3  
Old 01-05-2007, 05:11 AM
Default Re: Secure MySQL connection authentication?


howa wrote:

> currently we store user/pass in a plain php file, but we want to have a
> better method to protect the MySQL login authentication by hiding the
> real user name & password


Hiding it from whom? By putting it in a plain php file, you are hiding
it from all except those who can access the php file. So who else do
you wish to hide it from. The solution depends on this.

Reply With Quote
  #4  
Old 01-05-2007, 09:46 AM
Default Re: Secure MySQL connection authentication?


Captain Paralytic ¼g¹D¡G

> howa wrote:
>
> > currently we store user/pass in a plain php file, but we want to have a
> > better method to protect the MySQL login authentication by hiding the
> > real user name & password

>
> Hiding it from whom? By putting it in a plain php file, you are hiding
> it from all except those who can access the php file. So who else do
> you wish to hide it from. The solution depends on this.


okay, let consider it is a Perl script, running on the server, any
advice?

i.e. sometimes, you even don't want the root to know the password to
the remote Database...

Reply With Quote
  #5  
Old 01-05-2007, 09:46 AM
Default Re: Secure MySQL connection authentication?


Captain Paralytic ¼g¹D¡G

> howa wrote:
>
> > currently we store user/pass in a plain php file, but we want to have a
> > better method to protect the MySQL login authentication by hiding the
> > real user name & password

>
> Hiding it from whom? By putting it in a plain php file, you are hiding
> it from all except those who can access the php file. So who else do
> you wish to hide it from. The solution depends on this.


okay, let consider it is a Perl script, running on the server, any
advice?

i.e. sometimes, you even don't want the root to know the password to
the remote Database...

Reply With Quote
  #6  
Old 01-05-2007, 10:36 AM
Default Re: Secure MySQL connection authentication?

"howa" wrote:
> Captain Paralytic =BCg=B9D=A1G
>
>> howa wrote:
>>
>> > currently we store user/pass in a plain php file, but we want to have a
>> > better method to protect the MySQL login authentication by hiding the
>> > real user name & password


If you are using PHP you should put database account information in a
PHP include file and store that *outside* the webservers document root.

>> Hiding it from whom? By putting it in a plain php file, you are hiding
>> it from all except those who can access the php file. So who else do
>> you wish to hide it from. The solution depends on this.

>
> okay, let consider it is a Perl script, running on the server, any
> advice?
>
> i.e. sometimes, you even don't want the root to know the password to
> the remote Database...


This is not possible. The password must either be given interactively
or in a file. If it's in a file, root can always get a copy of that
file and use it (even if the password itself is encrypted).

There are multiple possibilities to store the password in a file:

- write it in the source (possibly obscured)
- write it in a MySQL option file (i.e. ~/.my.cnf)
- use a SSL certificate, no password but REQUIRE X509 ... in GRANT


XL
--
Axel Schwenke, Support Engineer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Reply With Quote
  #7  
Old 01-05-2007, 10:36 AM
Default Re: Secure MySQL connection authentication?

"howa" wrote:
> Captain Paralytic =BCg=B9D=A1G
>
>> howa wrote:
>>
>> > currently we store user/pass in a plain php file, but we want to have a
>> > better method to protect the MySQL login authentication by hiding the
>> > real user name & password


If you are using PHP you should put database account information in a
PHP include file and store that *outside* the webservers document root.

>> Hiding it from whom? By putting it in a plain php file, you are hiding
>> it from all except those who can access the php file. So who else do
>> you wish to hide it from. The solution depends on this.

>
> okay, let consider it is a Perl script, running on the server, any
> advice?
>
> i.e. sometimes, you even don't want the root to know the password to
> the remote Database...


This is not possible. The password must either be given interactively
or in a file. If it's in a file, root can always get a copy of that
file and use it (even if the password itself is encrypted).

There are multiple possibilities to store the password in a file:

- write it in the source (possibly obscured)
- write it in a MySQL option file (i.e. ~/.my.cnf)
- use a SSL certificate, no password but REQUIRE X509 ... in GRANT


XL
--
Axel Schwenke, Support Engineer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Reply With Quote
  #8  
Old 01-05-2007, 09:14 PM
Default Re: Secure MySQL connection authentication?

>> > currently we store user/pass in a plain php file, but we want to have a
>> > better method to protect the MySQL login authentication by hiding the
>> > real user name & password

>>
>> Hiding it from whom? By putting it in a plain php file, you are hiding
>> it from all except those who can access the php file. So who else do
>> you wish to hide it from. The solution depends on this.

>
>okay, let consider it is a Perl script, running on the server, any
>advice?
>
>i.e. sometimes, you even don't want the root to know the password to
>the remote Database...


If your script can know the password, so can root. If you encrypt
the password, your script also has to have the key to decrypt it.
If it isn't necessary to decrypt it, then it *IS* the password.
Some people have attempted this anyway (see Pay TV vendors with
their descrambler boxes) but they get hacked in spite of supposedly
"tamperproof" hardware.


Reply With Quote
  #9  
Old 01-05-2007, 09:14 PM
Default Re: Secure MySQL connection authentication?

>> > currently we store user/pass in a plain php file, but we want to have a
>> > better method to protect the MySQL login authentication by hiding the
>> > real user name & password

>>
>> Hiding it from whom? By putting it in a plain php file, you are hiding
>> it from all except those who can access the php file. So who else do
>> you wish to hide it from. The solution depends on this.

>
>okay, let consider it is a Perl script, running on the server, any
>advice?
>
>i.e. sometimes, you even don't want the root to know the password to
>the remote Database...


If your script can know the password, so can root. If you encrypt
the password, your script also has to have the key to decrypt it.
If it isn't necessary to decrypt it, then it *IS* the password.
Some people have attempted this anyway (see Pay TV vendors with
their descrambler boxes) but they get hacked in spite of supposedly
"tamperproof" hardware.


Reply With Quote
  #10  
Old 01-06-2007, 01:28 AM
Default Re: Secure MySQL connection authentication?


Gordon Burditt ¼g¹D¡G

> >> > currently we store user/pass in a plain php file, but we want to have a
> >> > better method to protect the MySQL login authentication by hiding the
> >> > real user name & password
> >>
> >> Hiding it from whom? By putting it in a plain php file, you are hiding
> >> it from all except those who can access the php file. So who else do
> >> you wish to hide it from. The solution depends on this.

> >
> >okay, let consider it is a Perl script, running on the server, any
> >advice?
> >
> >i.e. sometimes, you even don't want the root to know the password to
> >the remote Database...

>
> If your script can know the password, so can root. If you encrypt
> the password, your script also has to have the key to decrypt it.
> If it isn't necessary to decrypt it, then it *IS* the password.
> Some people have attempted this anyway (see Pay TV vendors with
> their descrambler boxes) but they get hacked in spite of supposedly
> "tamperproof" hardware.



consider some applications like e-banking system, how they protect your
data from being modified by the `root` account?

Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 08:13 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.