-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

===========================================================================
             AUSCERT External Security Bulletin Redistribution

                               ESB-2016.0975
                    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: 
   http://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2016-003.txt.asc

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

- -----BEGIN PGP SIGNED MESSAGE-----
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.

Abstract
========

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
=========================

Workaround
- - ----------

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

Solution
- - --------

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):
		usr.bin/calendar/calendar.c

	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:
		usr.bin/calendar/calendar.c

	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 
  http://ftp.NetBSD.org/pub/NetBSD/security/advisories/NetBSD-SA201X-NNN.txt.asc

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 $

- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJXElgDAAoJEAZJc6xMSnBuXCYP/0CZtcHO3bBjfoqmJjlDUHuA
vhuDpALl9dzrY43QFHLI1qf09IeoGXowA8RDcd8n8xN+v4hVdrPdjP+1kYTCE8jA
x6FubsdHwR5b4Vj+g26SMlAYFce1Uw6PghrjHAWe5mJXptYQjev+LikaNOQ6LNUS
fAODvAfyTmpq7pOYn0Q/mwKRTDRUVfcdCddSyw1Bv6dwqgJlBFKFBGHpsydYIMFB
GSiUisLwhBbtdS4lC0iAn+N8L0ZE8Mqiau17OBsjZAbhSGAxJqFgITBvdwAVWosk
D+FjZIuANX3PdDgaSXGtdDalca1+WCMSt+9M1ZBR/iTMRdJOp58ZqmU4bVOKrNzs
UzZWxz1pwoigy35kIRFhthIVooeh1SJbwyfFG2cZK/faQCTEF0tbEQRe/WFAdKUX
OHBDVsXsTh1DcpvKhuz2gxr+BGnMMJ/hrethJLSub2kz6o7yW2PjecbauV3RRfAs
4w86K80T4WmMC4ba/ekvbIkeAHP6JVcX6Ya9JqpfnNeRjRNPPsSU5XpFOmeNlEAo
ZKQuuKwoykxHQlsG2CiRiBoOtmZZTMEjcJDvt1d7+jyaDNkNLEfpjnRNHKeYBawh
VW6TOHJB1K5+9RnaFRk5eE2aMm/Hn48rOtF0L2nMzBN8jaWa82wCR8AP9q1H++he
Wtp/aPxRKQZrm/iKll/3
=pGey
- -----END PGP SIGNATURE-----

- --------------------------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:

        http://www.auscert.org.au/render.html?cid=1980

===========================================================================
Australian Computer Emergency Response Team
The University of Queensland
Brisbane
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.
===========================================================================
-----BEGIN PGP SIGNATURE-----
Comment: http://www.auscert.org.au/render.html?it=1967

iQIVAwUBVxRVon6ZAP0PgtI9AQIzbBAAohYmy3smZcuE6serbks3WDA+j+KWKgxe
Te8n4OGkLZ62l/sVD7YBezuUnXsh+3FYSHC6rpD8jHEsxL11agsNCo9oPJGOMykW
QDJ0lAQVLxEnEWonYHjgJnnG5XfpSAZbqEu4W2I5ZNRzYo/i0H2b/btyeG6YqtJC
BD+yca3ujQPhrlN2TcToo4dt9h6uDvNGZzd2EQVNyO9i1TuRAtk9OfM9wsDpm5je
Q/4lIiTDMYPv783eCmxvfqGXUdnHXJMewx2R+B8nbiRoA8G1hYZKPipBqyy1cXlI
Thi9w6cSAM37n6DKOfJ0sEUJL1PDNBlCAxw8dDgEkbuixn+Vuks+qXvYzg0WYsU5
GPC8xNFwT4RMJnQ7TY8m2v2lF3Mf9tGm5j0QfzhMlgb+20CjuiC+buwJ8jjDFjvC
9U+VIYKncRE9mm77d3tx7mDqa8q1QPkb+OwjzibjfA/Wu6iBG9w7fh+U+qOrTmuR
k88hXhoheuqAbUVAEBseedb2SJID+W8Lh/64PegYVpb0t2qnNBXc0M0kFiOOXQC2
TvQmabaXb33Ron4e/5nFRWmceYRQ11pOnaXLN55ZEmRLot58q1RuGqTvTufK2vUO
UcEiSA0JvYAqsWraKavEPogSaOHiD9KV8y03xHNAwok+x17WcXHXIr0jMUisohpE
baMKtDjoZCk=
=Kyf1
-----END PGP SIGNATURE-----