Re: password in md5 to connect to mysql instead of clear password
| From: | Simon Rees | Date: | Mon, 28 Feb 2005 10:44:14 +0000 |
| Subject: | Re: password in md5 to connect to mysql instead of clear password | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38697@lists.php.net to get a copy of this message | ||
On Sunday 27 February 2005 20:53, Micah Stevens wrote:
> I think about as safe as you can get is by putting the connection data
> out of the served directory, somewhere that's not directly accessable,
> and concentrate on system integrity. (security wise)
A refinement of this technique is available on Unix boxes to which you have
root access.
Create a simple program that can read data about passwords etc. from a file.
Create a file that can be read by the program you've written with the
'secrets' you want to keep secure in it. Make this file owned and readable
only by root.
Set the program owned by root, executable by everyone and suid.
This will allow any user that can execute programs on the machine to obtain
the password. Attackers who have just 'escaped' the web server root, say by
taking advantage of a coding flaw, will not be able to read the password
file. You can use groups to give finer grained access by making the program
executable by a specific group only. However if an attacker has managed to
obtain an account on your box they could probably just use a rootkit.
In practice I use a simple c program (for speed) to read the password file
and a system call in my php script to call the c program. A PHP program
could be used for reading the password file but will need to be executed by
a shebang rather than as a parameter to php.
I can post further details if anyone is interested.
cheers Simon
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Simon Rees | tech-lists@zodiac2000.co.uk |
ORA-03113: end-of-file on communication channel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~