You are not logged in.

#1 2007-11-27 13:49:45

FeatherMonkey
Member
Registered: 2007-02-26
Posts: 313

Bash and peeking at variables.

Could someone clarify, on chatting to someone they wished to use the root password as a variable.

Now my concern as the script is being run as a user the variable maybe accessable outside the script to others in the users group.

So my question is am I right and would it be possible to sneak a peek or catch the variable to get access to the root password? And if so how?

Last edited by FeatherMonkey (2007-11-27 13:50:01)

Offline

#2 2007-11-27 14:46:45

VikM
Member
Registered: 2007-11-10
Posts: 50

Re: Bash and peeking at variables.

Interesting, I don't know any method to see variables of a running sh script and I didn't search one for this answer. A proper way to allow users to run specific programs is by editing /etc/sudoers (has nice examples). That user does not need root privileges for anything, you can make sudo allow only the needed program.
I don't want to be rude, but having the root password in a file is ridiculous.

Offline

#3 2007-11-27 14:55:07

FeatherMonkey
Member
Registered: 2007-02-26
Posts: 313

Re: Bash and peeking at variables.

This was my initial thought. It's just I thought I'd seen something about doing this, via ps, tmp or maybe proc but am really unsure. I have searched a little but not had much joy.

The password wouldn't of been in the file but passed to it, which was my concern. OK it would be only a small window of opportunity but still if it was possible to peek at the variable outside the script.

Then I just felt escalating from user rights would of been just a case of waiting for them to run the script if it was possible to peek at the variable.

Edit
This wouldn't even be applicable to Arch iirc as arch's su won't take a password like that but that's for another thread.

Last edited by FeatherMonkey (2007-11-27 15:00:41)

Offline

#4 2007-11-27 15:05:33

VikM
Member
Registered: 2007-11-10
Posts: 50

Re: Bash and peeking at variables.

If the password is passed as an argument to the script, or by the script to something else, anyone can see it in that moment. This is why mysql hides the password when it is given on the command line (try "mysql -uroot -pblabla" and run "ps ax" in another terminal).

You can also try some smart group membership and suid bit, but sudo seems somehow better to me.

Offline

#5 2007-11-27 15:34:04

FeatherMonkey
Member
Registered: 2007-02-26
Posts: 313

Re: Bash and peeking at variables.

Thank you the mysql example was exactly what I needed, took some trying though.

As you typed I was trying something similar by using a script with a sleep and echo's but think you've confirmed what I thought.

Yes there is a small window of opportunity but then its an opportunity.

Offline

#6 2007-11-27 17:45:42

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Bash and peeking at variables.

Further, if you pass the password on the command line, it will show up in your history. You should be the only one with permission to read this file, but to me its still a potential weak point.

Offline

Board footer

Powered by FluxBB