Possible root compromose with bsdmainutils 6.0.x < 6.0.15 (Debian testing/unstable)

2004-09-01T00:00:00
ID SECURITYVULNS:DOC:6700
Type securityvulns
Reporter Securityvulns
Modified 2004-09-01T00:00:00

Description

Possible root compromise with calendar (bsdmainutils 6.0.x < 6.0.15)

Introduction

The calendar utility is a handy little tool that informs you about upcoming events. Each user can define his/her own calendar events. In Debian (and possibly other distributions as this option is builtin in calendar), calendar can be run from cron so that users get upcoming event notifications by mail. This can be abused to gain root access.

This vulnerability is also known CAN-2004-0793.

Systems affected

Debian testing and Debian unstable with the bsdmainutils package installed. (Versions 6.0 to 6.0.14 are vulnerable, >=6.0.15 is not)

How calendar works

The calendar program uses event files with this format:

<date><tab><event description>

This is not all however. Calender gives users the ability to include other event-files and define variables and macro's. To do this, it calls cpp (the C preprocessor) on the main event file and processes the output.

When called with the "-a" option, calendar will processes the event files of all users and send the result by mail.

The bsdmainutils package in Debian uses this feature from /etc/cron.daily/bsdmainutils. Luckily, it is not enabled by default since you have to uncomment an "exit 0" line in the cron script to activate it.

The problem

Calendar does not drop its privileges. In order to be useful when running with the "-a" option, it needs to run as root. By creating an event file as follows, we can get the hashed root password (on June 28th ;) :

define root Jun. 28<tab>cut_here

include </etc/shadow>

Jun. 28<tab>Birthday of Steven Van Acker Aug. 19<tab>Birthday of Andrew Griffith

(<tab> indicates an actual tab, so char '\t')

Since calendar is running as root, there will be no problem accessing the shadow password file. The result contains the hashed password of root, which can then be cracked.

Solution

Quick fix: don't run "calendar -a" as root ! Graham Wilson (the bsdmainutils package maintainer for Debian) has provided a fix for this issue. Please upgrade the package :)

Thanks to Graham Wilson for solving the problem and Jacques A. Vidrine (FreeBSD) for keeping me from making a foolish mistake ;)

greets, -- Steven

PS: happy birthday andrewg! ;)

Steven Van Acker deepstar@ulyssis.org

[ Need a challenge ? ] [ Visit http://www.pulltheplug.com ]