Date: Mon, 30 Aug 2004 10:05:26 +0200
From: Steven Van Acker <[email protected]>
To: [email protected]Subject: Possible root compromose with bsdmainutils 6.0.x < 6.0.15 (Debian testing/unstable)
--mYCpIKhGyMATD0i+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
this advisory was sent to the maintainers of the bsdmainutils package in
Debian testing/unstable.
With their agreement, I have waited to send it to bugtraq untill now.
To fix the vulnerability, upgrade your bsdmainutils package to version
6.0.15. This package is already in the unstable branch and should find
its way into the testing branch very soon.
(Sorry for the first mail, it's monday morning ;) This time I actually
attached the advisory)
greets,
--
Steven Van Acker
[email protected]
--mYCpIKhGyMATD0i+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="calendar_advisory.txt"
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
[email protected]
[ Need a challenge ? ]
[ Visit http://www.pulltheplug.com ]
--mYCpIKhGyMATD0i+--