Don't ask to ask, just ask | |
PerlMonks |
Handling passwords and sensitive databy zzspectrez (Hermit) |
on Jan 27, 2001 at 12:43 UTC ( [id://54731]=perlquestion: print w/replies, xml ) | Need Help?? |
zzspectrez has asked for the wisdom of the Perl Monks concerning the following question: The otherday, I discovered a security issue that is pretty obvious but which I had not considered before. I was running a perl script on my linux box as a privelaged user while also logged on as an unprivelaged user. I needed to kill a process. So I did ps aux to discover the pid. Well I noticed that in this output I was looking at the command line of the script running under my other login which was happy to share its password for all to see. Got me to thinking of how many scripts I have wrote that used something like the following code:
I cant think of how many simple scripts I have written that use this simple method of getting a username and password. It's hard to not write something like this because its easy to write and easy to use. Almost all of my web scripts I use to download my current bank statements, or download mail, etc use this method. 98% of these scripts I run on my home machine which for all purposes is a single user machine so it is not a big issues that the password from the command line is displayed. But on a multi-user system would be something to be concerned about and possibly overlooked. So this gets me to thinking.. What is the best way to handle passwords or semi-secure data like this. The following are my ideas. Read the data from <STDIN> and disable the screen echo for the password. This works effectively but has the side effect that it requires someone to type in the password making unusable for automated scripts run by cron or from other scripts.
Another solution would be to have a config file containing the username and password in the users home directory which is only readable by the user. This would enable the script to be run safely and automated. However this requires an additional config file for each user who runs the program.
What do you do!? THANKS!
Back to
Seekers of Perl Wisdom
|
|