-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 NetBSD Security Advisory 2019-003 ================================= Topic: Unprivileged user kernel stack disclosure in SIOCGIFCONF Version: NetBSD-current: affected prior to April 15, 2019 NetBSD 8.0: affected NetBSD 7.2: affected NetBSD 7.1.2: affected NetBSD 7.0.2: affected Severity: Local user may cause the kernel to run out of memory Fixed: NetBSD-current: April 15, 2019 NetBSD-8 branch: April 19, 2019 NetBSD-7 branch: April 19, 2019 NetBSD-7-2 branch: April 19, 2019 NetBSD-7-1 branch: April 19, 2019 NetBSD-7-0 branch: April 19, 2019 Please note that NetBSD releases prior to 7.1 are no longer supported. It is recommended that all users upgrade to a supported release. Abstract ======== An unprivileged user can leak a huge amount of kernel stack by issuing the 'SIOCGIFCONF' ioctl command. Technical Details ================= Kernel stack can be leaked to an unprivileged user at [1], because 'ifr' is uninitialized and only 'sa->sa_len' are copied to 'ifr.ifr_space'. The size of 'struct ifreq ifr' is 0x90 bytes and 'sa->sa_len' is usually 0x11 bytes. Hence, upto 0x7f bytes can be leaked. This can expose sensitive information, pointers to bypass KASLR, stack canaries which can be used to exploit stack buffer overflows, etc. [1] https://github.com/NetBSD/src/blob/trunk/sys/net/if.c#L3378 Solutions and Workarounds ========================= Update the kernel to a fixed version and reboot. To apply a fixed version from a releng build, fetch a fitting kern-GENERIC.tgz from nyftp.netbsd.org and extract the fixed binaries: cd /var/tmp ftp https://nycdn.NetBSD.org/pub/NetBSD-daily/REL/latest/ARCH/binary/sets/kern-GENERIC.tgz cd / tar xzpf /var/tmp/kern-GENERIC.tgz with the following replacements: REL = the release version you are using 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 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/path/to/file.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/docs/guide/en/chap-kernel.html Thanks To ========= Andy Nguyen for discovering and reporting the issue. 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-SA2019-003.txt.asc Information about NetBSD and NetBSD security can be found at http://www.NetBSD.org/ and http://www.NetBSD.org/Security/ . Copyright 2019, The NetBSD Foundation, Inc. All Rights Reserved. Redistribution permitted only in full, unmodified form. $NetBSD: NetBSD-SA2019-003.txt,v 1.2 2019/05/06 14:40:15 christos Exp $ -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJc0EdxAAoJEAZJc6xMSnBu6z0P/iv6HuhutIJAF6+cAQ1s1oZd x+dBFw/2Y6NWCPczcLf4U6hq5KQ49YMHp3Z+7WfS9A1ACsXvbwFwRd/NjDLqrR4o l9mxkpn0q5SdFIhcgx1ceBoBUBkL2p5r7fmLc6B+9rsMHKwoOwJcDjarl/tgEca+ zqqnCGkJMyFzcdTStAVIleCvxvv5gjKKFvTVr7dyXoeehuHImBgIF1PK5nMe5Ch/ 84Xe+D/0i58wXWLnZx+mT0gG3ZHVmyfRa1peKCccvx/uaEqVTbTSOkGwCt7TIJoC l5Y1uYcHSVymEJCPQhmEdu1a1yZsro1rm1PprBm/STlsWAb/50Dwv4BwfObYu/lv NBmQ77zH7OHRrvlZAVKlyHSsFt+4cwqs0M/Iian/lyto6A46jETfG8Pj5ssIzfOz TjhPDjAnCFsYsKDEzDGixReg/8brU+B0zVdwcXzhqoIo83u5wKD3u19N2gcJc/2S kN51c4w+WnMAVJ8S3bMBhWOgp3EMZ2qouT+Ux36ig58qPSlVKGYtEhvFVHXQ/gop p18//oCFnRSLsLmXNUz1Be5PczQUWDviCLzpevFx8E9jLgk19NWn8XG2BNrV///L RIa1zQ2GlcsXBw9YI5F+w6MMtBbqs3wd+3/NMnbMFwxVKPFvPmFDa/Xp0FN22DP7 t6JSTZ/7XJ2zfQsigW+C =5HPr -----END PGP SIGNATURE-----