|
|
#1 |
|
Prospect
Join Date: Mar 2003
Location: Brooklyn, NY
Posts: 40
|
I recently discovered something slightly disturbing by accident and cannot find any mention of it on the forums: When using the do shell script ... with administrator privileges command in applescript, the administrator password can show up using the ps command in the Terminal. To demonstrate, you can run this command from Script Editor:
Code:
do shell script "sleep 20" with administrator privileges Code:
ps -axww | grep sleep | grep -v grep Code:
18816 ?? S 0:00.01 sh -c echo '********' | sudo -p "" -S sleep 20 18818 ?? S 0:00.87 sleep 20 Thanks.
__________________
. . . |
|
|
|
|
|
#2 |
|
MVP
Join Date: Jan 2002
Location: Brisbane, Australia
Posts: 1,108
|
Yep, that is pretty ugly
I have found mention of it over a year ago here so it does not look like it is new, but I had never heard of it before..... (but the I don't applescript much)
__________________
Douglas G. Stetner UNIX Live Free Or Die Last edited by stetner; 08-29-2003 at 12:48 AM. |
|
|
|
|
|
#3 | |||||||||||||||||||
|
Prospect
Join Date: Mar 2003
Location: Brooklyn, NY
Posts: 40
|
Hmm...I read through that message thread, and it looks like the discussion there is concerned with the security risks of embedding your password inside an applescript (instead of prompting for it with a dialog window) and of modifying the behavior of the sudo command so that you can run a command with admin privileges without a password. These are both relevant security concerns of using the do shell script command, but they're separate from my main concern: that the do shell script ... with administrator privileges pipes the user's password to the command line using echo, which makes the password visible using the ps command. Thanks for the reply, though. Anyone else have thoughts on this?
__________________
. . . |
|||||||||||||||||||
|
|
|
|
|
#4 |
|
Prospect
Join Date: Jul 2002
Posts: 14
|
You can put it in the background to avoid this issue
Code:
do shell script "sleep 20 &" with administrator privileges |
|
|
|
|
|
#5 | |||||||||||||||||||
|
Prospect
Join Date: Mar 2003
Location: Brooklyn, NY
Posts: 40
|
Thanks, greggo (and JB LE STANG). That had occurred to me before, but I didn't expect that the applescript would receive the output of terminal command you're running, or be able to tell when (or if) the terminal command terminates. Now that I actually test it, it turns out I was wrong: it does work safely and it does wait until the terminal command terminates, and returns the output. Using "&" to run commands in the background seems to be the best workaround at the moment.After testing this method there is one thing I noticed that you applescripters out there should watch out for. If you're running multiple commands with do shell script, linking your commands together with ";" causes the sudo command (and your password) to be visible with ps again. So doing this: Code:
do shell script "sleep 10 ; sleep 10 &" with administrator privileges Code:
do shell script "sh -c \"sleep 10 ; sleep 10\" &" with administrator privileges While using the above method seems to be safe, I still think there is is a security flaw here that Apple should fix.
__________________
. . . |
|||||||||||||||||||
|
|
|
![]() |
|
|