Originally Published: Friday, 3 September 1999 Author: Quentin Cregan
Published to: news_enhance_security/Security News Page: 1/1 - [Printable]

Vixie Cron contains root compromise, patches available

Vixie cron was found to have a root compromise this week. Patches are now available for all major distributions.

   Page 1 of 1  

from BugTraq:

To: BugTraq Subject: Vixie Cron version 3.0pl1 vulnerable to root exploit Date: Sun Aug 29 1999 02:42:42 Author: Martin Schulze Message-ID: <19990829084242.U29569@finlandia.infodrom.north.de>

Red Hat has recently released a Security Advisory (RHSA-1999:030-01) covering a reverse denial of service bug in the vixie cron package. As user you could restart sendmail even if the host should not receive mail through the SMTP port.

Further investigation discovered that it was even worse. Vixie cron runs as root at the time sending acknowledge mail to a user. Passing arbitrary parameters to sendmail at this time leads into a possible root exploit (like -C/tmp/myexploitsendmail.cf).

Olaf Kirch has developed the following patch that will send the mail as user instead of root and removes the possibility to pass arguments to the installed MTA.

Fixed packages available:

Red Hat - already released

Caldera - in progress

Debian - in progress

Slackware - no Vixie cron, they use Dillen's Cron Daemon instead

diff -ur cron-3.0pl1.orig/config.h cron-3.0pl1/config.h --- cron-3.0pl1.orig/config.h Thu Aug 26 15:03:15 1999 +++ cron-3.0pl1/config.h Thu Aug 26 17:00:14 1999 @@ -42,11 +42,13 @@ */

#define MAILCMD _PATH_SENDMAIL /*-*/ -#define MAILARGS "%s -FCronDaemon -odi -oem -or0s %s" /*-*/ +#define MAILARGS "%s -FCronDaemon -odi -oem %s" /*-*/ /* -Fx = set full-name of sender * -odi = Option Deliverymode Interactive * -oem = Option Errors Mailedtosender * -or0s = Option Readtimeout -- don't time out + * XXX: sendmail doesn't allow -or0s when invoked + * by joe user. --okir */

/* #define MAILCMD "/bin/mail" /*-*/ diff -ur cron-3.0pl1.orig/cron.h cron-3.0pl1/cron.h --- cron-3.0pl1.orig/cron.h Thu Aug 26 15:03:16 1999 +++ cron-3.0pl1/cron.h Thu Aug 26 16:45:07 1999 @@ -221,7 +221,7 @@ entry *load_entry __P((FILE *, void (*)(), struct passwd *, char **));

-FILE *cron_popen __P((char *, char *)); +FILE *cron_popen __P((char *, char *, entry *));

/* in the C tradition, we only create diff -ur cron-3.0pl1.orig/do_command.c cron-3.0pl1/do_command.c --- cron-3.0pl1.orig/do_command.c Thu Aug 26 15:03:16 1999 +++ cron-3.0pl1/do_command.c Thu Aug 26 17:14:23 1999 @@ -95,6 +95,21 @@ usernm = env_get("LOGNAME", e->envp); mailto = env_get("MAILTO", e->envp);

+ /* Check for arguments */ + if (mailto) { + const char *end; + + /* These chars have to match those cron_popen() + * uses to split the command string */ + mailto += strspn(mailto, " \t\n"); + end = mailto + strcspn(mailto, " \t\n"); + if (*mailto == '-' || *end != '\0') { + printf("Bad Mailto karma.\n"); + log_it("CRON",getpid(),"error","bad mailto"); + mailto = NULL; + } + } + #ifdef USE_SIGCHLD /* our parent is watching for our death by catching SIGCHLD. we * do not care to watch for our children's deaths this way -- we @@ -368,7 +383,7 @@ (void) gethostname(hostname, MAXHOSTNAMELEN); (void) snprintf(mailcmd, sizeof(mailcmd), MAILARGS, MAILCMD, mailto); - if (!(mail = cron_popen(mailcmd, "w"))) { + if (!(mail = cron_popen(mailcmd, "w", e))) { perror(MAILCMD); (void) _exit(ERROR_EXIT); } diff -ur cron-3.0pl1.orig/popen.c cron-3.0pl1/popen.c --- cron-3.0pl1.orig/popen.c Thu Aug 26 15:03:16 1999 +++ cron-3.0pl1/popen.c Thu Aug 26 17:01:24 1999 @@ -44,8 +44,9 @@ static int fds;

FILE * -cron_popen(program, type) +cron_popen(program, type, e) char *program, *type; + entry *e; { register char *cp; FILE *iop; @@ -115,6 +116,14 @@ } (void)close(pdes[1]); } + /* Lose root privilege */ + setgid(e->gid); +# if defined(BSD) || defined(POSIX) + initgroups(env_get("LOGNAME", e->envp), e->gid); +# endif + setuid(e->uid); + chdir(env_get("HOME", e->envp)); + #if WANT_GLOBBING execvp(gargv[0], gargv); #else

The exploit has also been developed by Olaf Kirch:

Set the user's crontab to

MAILTO=" -C/tmp/myexploitsendmail.cf" * * * * * ls

In /tmp/myexploitsendmail.cf you basically modify the local mailer:

O DefaultUser=root:root Mlocal, P=/tmp/hackme, F=lsDFMAw5:/|@qXfmnz9, S=10/30, R=20/40, T=DNS/RFC822/X-Unix, A=mail.local -l

i.e. remove the S flag, and set DefaultUser.

-- ---------------------------------------------------------------------- Debian Security Team http://www.debian.org/security/

debian-security-announce@lists.debian.org





   Page 1 of 1