Qiang (
[email protected]) wrote:
: hello,
: i have a module connect to a database and return some information for
: user. the database name and password are stored in it.
: now the user will run another perl file which use the module. however,
: i don't know how do i pretect the database password from user?
: i heard about setuid, but it seems to have it's own security problem.
setuid to root is a security problem, setuid to some other non-priv
user is not inherently a problem.
: can anyone recommend elegant way to solve this problem ?
Set the file containing the password to be owned by a non-priv user set up
for this task. Do not allow any user other than the owner (which is a
dummy account) to read that password file.
Set the script that reads the password to be suid to that non-priv user.
The script can now read the password, but a user running the script
cannot, by themselves, read the password.
You must now make sure that the script is secure, in the sense that only
the appropriate people can run it, and that when they run it they can only
use it for the purpose for which it is intended.
Control who can run the script however you wish, depending on the
circumstances. One technique is for the script to be group
read/executable, and owned by a group set up for this purpose. Users who
should be able to run the script are placed in that group.
The script itself must control how it is used. I think taint mode is
turned on by default in this situation, but in any case it should be,
which helps to ensure the script has no holes, and of course the script
must not do anything such as allow a user to access the command line via
the script, or to allow them to access the inner variables of the script.
(Does taint turn of debugging? I have never thought about it, but I hope
it does.)