From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 31987 invoked from network); 11 Nov 1998 15:56:01 -0000 Received: from mail.redhat.com (199.183.24.239) by mail2.redhat.com with SMTP; 11 Nov 1998 15:56:01 -0000 Received: from doxx.net (qmailr@arsenic.doxx.net [209.77.122.5]) by mail.redhat.com (8.8.7/8.8.7) with SMTP id KAA01233 for ; Wed, 11 Nov 1998 10:56:00 -0500 Received: (qmail 284 invoked by uid 0); 11 Nov 1998 15:53:40 -0000 Received: from arsenic.doxx.net (HELO beefcake) (209.77.122.5) by arsenic.doxx.net with SMTP; 11 Nov 1998 15:53:40 -0000 Message-Id: <3.0.5.32.19981111094832.009ad8f0@localhost> X-Sender: blyon@localhost X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.5 (32) Date: Wed, 11 Nov 1998 09:48:32 -0600 To: axp-list@redhat.com From: "Barrett G. Lyon" Subject: [Linux] klogd 1.3-22 buffer overflow Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Hey funny, here was our nive syslogd problem that the list figured out months ago. >Delivered-To: blyon@NETPR.COM >Approved-By: aleph1@DFW.NET >X-Hate: Where do you want to go to die? >Date: Thu, 10 Sep 1998 10:26:06 +0200 >Reply-To: Michal Zalewski >Sender: Bugtraq List >From: Michal Zalewski >Subject: [Linux] klogd 1.3-22 buffer overflow >To: BUGTRAQ@NETSPACE.ORG > >Good morning, > >This time - buffer overflow in Linux klogd daemon from sysklogd-1.3 >package (up to release 22 - affects Red Hat 5.x and Slackware 3.x, no data >about other distributions). > >The problem: > >Kernel messages are stored in 4 kB cyclic printk ring. Klogd reads this >buffer using /proc/kmsg to 4 kB long buffer, that's good. But then, data >is split into lines, by copying data until '\n' is reached. What a pity, >line buffer is only 1 kB long - sometimes, it's not enough... Exploitable? >Could be... > >Impact: > >To exploit this security hole, we have to generate very long kernel >message (or a lot of short messages with no '\n' inside). There are two >potential ways of doing this: > >a) In kernel source (or any of installed modules), find printk not > terminated with '\n'. There are some old, obscure messages both in > 2.0.xx and 2.1.xxx. Yep, but what now? You have to generate it :-S > It's especially easy when poking with strange network packets > (so it's possible to perform remote DoS attack). Unfortunately, DoS > if probably all you can do - enjoy SEGV in klogd daemon, or (better?), > by overwriting fd to /proc/kmsg lyingo on the stack, increase LA and > generate enormous amount of error messages like 'Cannot read /proc > filesystem', apparently from kernel. > >b) ...or, in kernel (2.1.xxx is more interesting), locate any printk with > %s in format string, where substituted string depends in some way on > luser (process/filename?). Then, you should be able to parse arbitrary > shellcode into buffer, obtaining root privledges. > >Solution: > >In klog.c, at the beginning, there are two '#define's. First one is >responsible for main buffer size - don't change it, 4096 should be ok. The >next one is line buffer size - hmm, replace 1024 with 4096, for example... >Or, better, implement some range checking ;> > >Quick vunerability test: > >-- gcc -c -O3 test.c; insmod test; rmmod test -- >#define MODULE >#define __KERNEL__ > >#include >#include >#include >#include >#include >#include >#include >#include > >int init_module(void) { > printk("INSERT_ABOUT_2000_BYTES_OF_JUNK_HERE\n"); return 0; >} > >void cleanup_module(void) {} >-- > >Modify this source by increasing amount of junk after printk, compile, >insmod and watch out what happened to klogd. > >_______________________________________________________________________ >Michal Zalewski [lcamtuf@ids.pl] [ENSI / marchew] [dione.ids.pl SYSADM] >[http://linux.lepszy.od.kobiety.pl/~lcamtuf/] <=--=> bash$ :(){ :|:&};: >[voice phone: +48 (0) 22 813 25 86] ? [pager (MetroBip): 0 642 222 813] >Iterowac jest rzecza ludzka, wykonywac rekursywnie - boska [P. Deutsch] > -- Barrett G. Lyon PGP: www.netpr.com/pgpkeys Data & Network Security Consultant Fax: 310-737-0196 Network Presence, LLC Email: blyon@netpr.com --