Hash: SHA1

             AUSCERT External Security Bulletin Redistribution

                    Privilege escalation in calendar(1)
                               18 April 2016


        AusCERT Security Bulletin Summary

Product:           calendar
Publisher:         NetBSD
Operating System:  NetBSD
Impact/Access:     Increased Privileges -- Existing Account
Resolution:        Patch/Upgrade

Original Bulletin: 

- --------------------------BEGIN INCLUDED TEXT--------------------

Hash: SHA1

		 NetBSD Security Advisory 2016-003

Topic:		Privilege escalation in calendar(1)

Version:	NetBSD-current:		source prior to Wed, Jul 1st 2015
		NetBSD 7.0:		not affected
		NetBSD 6.1 - 6.1.5:	affected
		NetBSD 6.0 - 6.0.6:	affected
		NetBSD 5.2 - 5.2.3:	affected
		NetBSD 5.1 - 5.1.5:	affected

Severity:	Local privilege escalation

Fixed:		NetBSD-current:		Jul 1st, 2015
		NetBSD-7 branch:	Jul 1st, 2015
		NetBSD-7-0 branch:	Jul 1st, 2015
		NetBSD-6 branch:	Jul 1st, 2015
		NetBSD-6-1 branch:	Jul 1st, 2015
		NetBSD-6-0 branch:	Jul 1st, 2015
		NetBSD-5 branch:	Jul 1st, 2015
		NetBSD-5-2 branch:	Jul 1st, 2015
		NetBSD-5-1 branch:	Jul 1st, 2015

Please note that NetBSD releases prior to 5.1 are no longer supported.
It is recommended that all users upgrade to a supported release.


calendar(1) is a utility to process text files and displays lines that match
certain dates. The -a flag which is used to process the default calendar
files of all users and mails them the results. This flag requires super-user
privileges which are not dropped properly when executing external programs.

calendar(1) with -a option is executed by daily(5) maintenance script.

Technical Details

calendar(1) requires super-user privileges in order to process calendar
files of each user. When processing particular account, code is dropping its
privileges incorrectly. The code changes only effective uid (euid) and
effective gid (egid) of running process, and executes external programs such
as cpp(1) and sendmail(1). This can be potentially used to escalate attacker
privileges or process files which are readable by super-user only.
Additionally, initgroups(3) call was missing. Thus, any supplementary groups
in effect when it is started are also exposed.

Solutions and Workarounds

- - ----------

Set run_calendar=NO in daily.conf(5) in order to prevent invoking calendar(1)
by daily(5) maintenance script.

- - --------

1.) Binary update of affected versions (root is required to extract):
To apply a fixed version from a releng build, fetch a matching base.tgz
from nyftp.netbsd.org and extract the fixed binaries:

# cd /var/tmp
# ftp http://nyftp.netbsd.org/pub/NetBSD-daily/REL/BUILD/ARCH/binary/sets/base.tgz
# cd /
# tar xzpf /var/tmp/base.tgz /usr/bin/calendar

with the following replacements:
REL   = the branch version you are using (e.g., netbsd-7-0, netbsd-6-1)
	[Note: netbsd-X represents the current _STABLE branch. Run "uname -v"
	 to view which version you are updating. (e.g. netbsd-6 = 6.1_STABLE)
	 You would use netbsd-X if you have _STABLE in your uname version.]
BUILD = the source date of the build. 201507020000Z and later will fix
ARCH  = your system's architecture (e.g., i386, amd64, alpha)

	(e.g., /netbsd-7-0/201511200000Z/amd64/)

2.) Source update of affected versions (root is required for install):
The following instructions describe how to upgrade your calendar(1)
binaries by updating your source tree and rebuilding and installing
a new version of calendar(1).

* NetBSD-current:

	Systems running NetBSD-current dated from before 2015-07-01
	should be upgraded to NetBSD-current dated 2015-07-02 or later.

	The following files/directories need to be updated from the
	netbsd-current CVS branch (aka HEAD):

	To update from CVS, re-build, and re-install calendar(1):
		# cd src
		# cvs update -d -P usr.bin/calendar/calendar.c
		# cd usr.bin/calendar
		# make USETOOLS=no cleandir dependall
		# make USETOOLS=no install

* NetBSD 5.* and 6.*:

	Systems running NetBSD 5.* and 6.* sources dated from before
	2015-07-01 should be upgraded from NetBSD 6.* sources dated
	2015-07-02 or later.

	The following files/directories need to be updated from the
	netbsd-5, netbsd-5-1, netbsd-5-2, netbsd-6, netbsd-6-0, or
	netbsd-6-1 branches:

	To update from CVS, re-build, and re-install calendar(1):

		# cd src
		# cvs update -r <branch_name> -d -P usr.bin/calendar/calendar.c
		# cd usr.bin/calendar
		# make USETOOLS=no cleandir dependall
		# make USETOOLS=no install

Thanks To

David Holland for reporting and providing fix for this issue.

Revision History

	2016-04-16	Initial release

More Information

Advisories may be updated as new information becomes available.
The most recent version of this advisory (PGP signed) can be found at 

Information about NetBSD and NetBSD security can be found at
http://www.NetBSD.org/ and http://www.NetBSD.org/Security/ .

Copyright 2015, The NetBSD Foundation, Inc.  All Rights Reserved.
Redistribution permitted only in full, unmodified form.

$Id: NetBSD-SA2016-003.txt,v 1.1 2016/04/16 15:18:30 christos Exp $

Version: GnuPG v1


- --------------------------END INCLUDED TEXT--------------------

You have received this e-mail bulletin as a result of your organisation's
registration with AusCERT. The mailing list you are subscribed to is
maintained within your organisation, so if you do not wish to continue
receiving these bulletins you should contact your local IT manager. If
you do not know who that is, please send an email to auscert@auscert.org.au
and we will forward your request to the appropriate person.

NOTE: Third Party Rights
This security bulletin is provided as a service to AusCERT's members.  As
AusCERT did not write the document quoted above, AusCERT has had no control
over its content. The decision to follow or act on information or advice
contained in this security bulletin is the responsibility of each user or
organisation, and should be considered in accordance with your organisation's
site policies and procedures. AusCERT takes no responsibility for consequences
which may arise from following or acting on information or advice contained in
this security bulletin.

NOTE: This is only the original release of the security bulletin.  It may
not be updated when updates to the original are made.  If downloading at
a later date, it is recommended that the bulletin is retrieved directly
from the author's website to ensure that the information is still current.

Contact information for the authors of the original document is included
in the Security Bulletin above.  If you have any questions or need further
information, please contact them directly.

Previous advisories and external security bulletins can be retrieved from:


Australian Computer Emergency Response Team
The University of Queensland
Qld 4072

Internet Email: auscert@auscert.org.au
Facsimile:      (07) 3365 7031
Telephone:      (07) 3365 4417 (International: +61 7 3365 4417)
                AusCERT personnel answer during Queensland business hours
                which are GMT+10:00 (AEST).
                On call after hours for member emergencies only.
Comment: http://www.auscert.org.au/render.html?it=1967