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

klogd-linux.txt

klogd-linux.txt
Posted Sep 19, 2000
Authored by Jouko Pynnonen | Site klikki.fi

Kernel logging daemon klogd in the sysklogd package for Linux contains a "format bug" making it vulnerable to local root compromise (successfully tested on Linux/x86). There's also a possibility for remote vulnerability under certain (rather unprobable) circumstances and a more probable semi-remote exploitableness with knfsd.

tags | exploit, remote, x86, kernel, local, root
systems | linux
SHA-256 | 2ecbd0ed65cc65018f64e392edb56708bf8a2ff389e963f1c9c260946bd00f25

klogd-linux.txt

Change Mirror Download
OVERVIEW

Kernel logging daemon klogd in the sysklogd package for Linux contains a
"format bug" making it vulnerable to local root compromise (successfully
tested on Linux/x86). There's also a possibility for remote vulnerability
under certain (rather unprobable) circumstances and a more probable
semi-remote exploitableness with knfsd.



BUG DETAILS

Normally klogd reads kernel messages from /proc/kmsg and after some
processing passes them to syslogd, which in turn writes the messages to
log file(s) as defined in syslog.conf.

The erroneous function calls are located in function LogLine(), klogd.c
lines 680 and 707:

Syslog( LOG_INFO, line_buff );

Each newline-postfixed kernel message goes to Syslog() as a format
string. Before passing the string to Syslog(), the LogLine() function
does some simple processing. Kernel addresses of form [<address>] are
translated to symbol names and '%' chars are checked and duplicated to
avoid format problems. The logics however fail to handle %-symbols
inside a [<foo>] symbol marker, so a malicious user can forge a kernel
message like "[<%s %s %s %s>]" which would be enough to kill klogd with
a segmentation fault. Possibilities of executing arbitrary code are
discussed below.




EXPLOITATION POSSIBILITIES

The vulnerability is exploitable for anyone who can feed strings in the=20
kernel log. There are many ways to do this locally; for example a=20
connect() call with an improperly initialized sockaddr structure
generates a warning to the kernel log containing the program name.
However the program name is taken from task_struct->comm which is a
16-byte buffer. The required "[<" takes 2 bytes so the space gets short
for a conventional shellcode and return address. The warning is printed
only once so exploiting with just this message is probably difficult, but
other warnings in the kernel make it possible.

Other possibilities include special kernel modules that call printk() to
log their things to kernel log, or various device drivers. The driver for
/dev/mixer for instance can be trivially made log a string containing a
31-byte user defineable substring if /dev/mixer is openable (as it is per
default in many systems).

The exploitation process itself isn't so trivial. The buffer in question
is declared static so it's mapped to a low memory address; there's
nothing user-defineable or otherwise usable in stack. I haven't been able
to produce a program doing a standard "%n" exploitation, but it is
possible to create a buffer overflow condition elsewhere in the program
in conjunction with the format bug. If the format string contains
something like "%2000d", a local buffer in vsyslog() overflows. This
function is called from Syslog() and does no bound checking but trusts
Syslog() checks. In addition, "%m" in the format string expands to the
error message (from strerror()) which can be used to "push" the end of
the string further in the memory, making it possible to build a longer
shellcode using multiple klogd messages if needed.

According to my quick test with a knfsd-enabled system, the driver can be
tricked to printk() path names with some race conditioning, which is
probably one of the easiest exploit methods where available.



VENDOR PATCHES

Linux distribution vendors have been informed about the problem via
vendor-sec@lst.de a week ago; patches and advisories will be out today.



CREDITS AND ACKNOWLEDGEMENTS

Vulnerability discovered by:
Jouko Pynn=F6nen

Greets and thanks to:
Esa Etel=E4vuori, vendor-sec team, cc-opers@IRCNet





--
Jouko Pynn=F6nen Online Solutions Ltd Secure your Linux -
jouko@solutions.fi https://www.secmod.com

Login or Register to add favorites

File Archive:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    3 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    14 Files
  • 12
    Nov 12th
    20 Files
  • 13
    Nov 13th
    63 Files
  • 14
    Nov 14th
    18 Files
  • 15
    Nov 15th
    8 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    17 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 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