Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

NetBSD Security Advisory 2021-002: Incorrect permissions in kernfs



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

		 NetBSD Security Advisory 2021-002
		 =================================

Topic:		Incorrect permissions in kernfs

Version:	NetBSD-current:		affected between March 3, 2020 and July 6, 2021
		NetBSD 9.2:		affected
		NetBSD 9.1:		affected
		NetBSD 9.0:		affected
		NetBSD 8.*:		not affected

Severity:	Local user may read any file on the root volume

Fixed:		NetBSD-current:		July 6, 2021
		NetBSD-9 branch:	July 6, 2021

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


Abstract
========

The /kern file system contains references to the device the root
volume was mounted from. It was discovered that the permissions were
incorrect and allow any local user to read the device, thus allowing
any local user to read any file on the root volume.


Technical Details
=================

The files /kern/rootdev and /kern/rrootdev are internally-generated
device special files that refer to the device the root volume was
mounted from. Until July 6, 2021 they were presented as mode 444
(readable to all users). Prior to February 3, 2020 (February 12 on the
NetBSD-9 branch, then at 9.0_RC2) this was harmless because these
device special files did not actually work; however, that problem was
corrected without noticing that the permissions were unsafe.


Solutions and Workarounds
=========================

Immediate workaround: unmount /kern and mark it "noauto" in
/etc/fstab. This will work (without impacting system functionality)
for all systems other than Xen DOM0. Unfortunately Xen requires access
to other elements in kernfs. 

Note that while chmod on the offending files appears to succeed, it
does not take and is not an adequate workaround.

To fix the underlying problem, update the kernel.

To apply a fixed version from a releng build, fetch a fitting
kern-GENERIC.tar.xz, kern-GENERIC_KASLR.tar.xz, kern-XEN3_DOM0.tar.xz,
or kern-XEN3_DOMU.tar.xz (depending on which kernel you are using;
uname -v will show, among other things, the name of the running
kernel) from nycdn.NetBSD.org and extract the fixed binaries:

cd /var/tmp
ftp https://nycdn.NetBSD.org/pub/NetBSD-daily/REL/BUILD/ARCH/binary/sets/kern-GENERIC.tar.xz (or whichever)
cd /
tar xzpf /var/tmp/kern-GENERIC.tar.xz

with the following replacements:
REL   = the release version you are using
BUILD = the source date of the build. 202107060400Z and later will fit
ARCH  = your system's architecture

The following instructions describe how to upgrade your kernel by
updating your source tree and rebuilding and installing a new version.

For affected NetBSD versions, you need to obtain fixed kernel sources,
rebuild and install the new kernel, and reboot the system.
                                      
The fixed source may be obtained from the NetBSD CVS repository.        
The following instructions briefly summarise how to upgrade your        
kernel.  In these instructions, replace:

  ARCH     with your architecture (from uname -m), and                  
  KERNCONF with the name of your kernel configuration file.    

To update from CVS, re-build, and re-install the kernel:

	# cd src
	# cvs update -d -P sys/miscfs/kernfs/kernfs_vnops.c
	# ./build.sh kernel=KERNCONF
	# mv /netbsd /netbsd.old
	# cp sys/arch/ARCH/compile/obj/KERNCONF/netbsd /netbsd 
	# shutdown -r now

For more information on how to do this, see:    

   http://www.NetBSD.org/guide/en/chap-kernel.html


Thanks To
=========

David A. Holland
Martin Husemann
Jonathan A. Kollasch
Jared McNeill


Revision History
================

	2021-07-14	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-SA2021-NNN.txt.asc

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

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

$NetBSD: NetBSD-SA2021-002.txt,v 1.1 2021/07/14 17:48:26 christos Exp $
-----BEGIN PGP SIGNATURE-----

iQIcBAEBAgAGBQJg7yNrAAoJEIkmHhf170n/MNwP/iD+dkuOVX5GVL+eSiCyCBAa
kHZbyg8jMNTJB636b8/gwDl7Jf0x8K+B/2jAeO2wrYwBzSPtlpI4K/6cQrjQ8Yc8
DasPy2x0qmaWZc744/2MlVieStD0bNHS6uw+Fm+MFPeNtecVNg94Qsbs7tzqK1dw
PueRPkRSafBkdmlffrmKNDASUZv2fUgOPL360Up8vIyfa3V1OAoCrJ18pIFjjiso
rHzPXlLhc+DonvNwxzsk3JbGpkyC8URUhJ7r666Z2w2TWWfKOnJFhJvR2uw+yN1K
v+2r1o+QpZMKw2xj4vvep+aefWxvyxmIBTgq/6vfiSOEx6TUFru6hgP11U+wnvBi
lTdAWs9KNshE5/7yM60QrT9b72hPe1RvQn3CEn/ojVn9Xc3e9rWQaC/PV/ZqjxBl
IRSH2NSs5IGgaUrLDwRwwNqPAPK/C7A4W/J87G+HemE60AuX7Abmqa1jVSW3wX0u
HSv+VIoctHB+Q7+YKVH+85pyO5sOD7lFcoF9s0EgtI0ngXW35BT5efkd/iOSB9rg
s5OR5r1nGILYZQLh/gZTt4d1eyT6IxaKUhqi4dhRvfxGDkMHXjBNwt1yQJPwSvkP
vNgWz2+bT19rJYXYKtkjah4WpMxGalcbQHefCZ303P0aoOh5pHFrFZP6kv5kp/Kk
an5/XG1en6mcRexjZ3wT
=AguD
-----END PGP SIGNATURE-----



Home | Main Index | Thread Index | Old Index