deadsimple BSD Security Advisories and Announcements

NetBSD Security Advisory 2022-004: procfs(5) missing permission checks

Hash: SHA256

		 NetBSD Security Advisory 2022-004

Topic:		procfs(5) missing permission checks

Version:	NetBSD-current:		affected prior to 2022-06-18
		NetBSD 9.2:		affected
		NetBSD 8.2:		affected

Severity:	Malicious user may read from opened file descriptors by other

Fixed:		NetBSD-current:		June 17, 2022
		NetBSD-9 branch:	June 17, 2022
		NetBSD-8 branch:	June 17, 2022

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


Due to missing permission checks it was possible to reuse open descriptors
which are exposed in the procfs(5) [pid]/fd/ directory. It might allow
malicious user to bypass permission checks and read data from opened descriptor
under some circumstances.

Technical Details

Directory fd/ which is available per process in the procfs(5) is exposing all
opened file descriptors by a process, because of the missing VOP_ACCESS check
during the VOP_LOOKUP(9) operation. Due to lack of proper access verification,
malicious user is allowed to open files from the directory with the file
descriptors, because permissions of the directory are not effectively checked.
An example scenario that leads to data leak is as follows: the file with
permissions 644 protected by the directory permissions 700, if process opened
the file, it is possible to obtain file descriptor by malicious user by
opening it directly from the exposed fd/ folder by the procfs(5).

Solutions and Workarounds

Immediate workaround: unmount procfs(5) and mark it "noauto" in /etc/fstab.
Please note that some programs may need access to procfs(5) in order to work

To apply a fixed version from a releng build, fetch a fitting kern-GENERIC.tgz
from and extract the fixed binaries:

cd /var/tmp
cd /
tar xzpf /var/tmp/kern-GENERIC.tgz

with the following replacements:
REL   = the release version you are using
BUILD = the source date of the build. 20220618 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
of the kernel.

For all 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/procfs/procfs_vnops.c
	# ./ 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:

Thanks To

Mateusz Kocielski (shm@) who analyzed this problem and supplied the fixes.

Revision History

	2022-10-04	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

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

$Id: NetBSD-SA2022-004.txt,v 1.1 2022/10/04 13:48:36 christos Exp $