Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 53009 - net-dialup/l2tpd: bss-based buffer overflow
Summary: net-dialup/l2tpd: bss-based buffer overflow
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: High major (vote)
Assignee: Gentoo Security
URL:
Whiteboard: C0 [glsa] krispy
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-04 13:37 UTC by Sune Kloppenborg Jeppesen (RETIRED)
Modified: 2023-10-16 01:19 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2004-06-04 13:37:16 UTC
Just posted on FD not sure if it is real or not. Opening a bug so we can keep track of it.

Ripped directly from mail:

All versions of l2tpd contain a bss-based buffer overflow. After
circumventing some minor obstacles (i.e., faking a L2TP tunnel
establishment) the overflow can be triggered by sending a specially
crafted packet.

The crucial code can be found in write_packet() in control.c:

    static unsigned char wbuf[MAX_RECV_SIZE];
    int pos = 0;
    [..]
    e = PPP_FLAG;
    wbuf[pos++] = e;
    for (x = 0; x < buf->len; x++)
    {
        e = *((char *) buf->start + x);
        if ((e < 0x20) || (e == PPP_ESCAPE) || (e == PPP_FLAG))
        {
            /* Escape this */
            e = e ^ 0x20;
            wbuf[pos++] = PPP_ESCAPE;
        }
        wbuf[pos++] = e;

    }
    wbuf[pos++] = PPP_FLAG;

Nota bene: buf->len can be upto 4080 = 4096 (=: MAX_RECV_SIZE) - 16.

It might be hard or even impossible to exploit this buffer overflow.

Thomas Walpuski
Comment 1 Thierry Carrez (RETIRED) gentoo-dev 2004-06-15 12:49:20 UTC
A few more pointers :

Debian has an open bug about it at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=252973
and osvdb a reference at http://www.osvdb.org/6726

It's still unconfirmed, though.
Comment 2 Thierry Carrez (RETIRED) gentoo-dev 2004-07-11 07:10:07 UTC
Debian issued a fixed package, so we can assume there is a bug, even if it's difficult to exploit. 

The fix appears in the diff file at : http://http.us.debian.org/debian/pool/main/l/l2tpd/l2tpd_0.70-pre20031121-2.diff.gz but it's applied to a 0.70_pre version they got from l2tpd repository. It might be sufficient to take the following and apply it to control.c :

------------------------------------------------
     wbuf[pos++] = e;
     for (x = 0; x < buf->len; x++)
     {
+		// we must at least still have 4 bytes left in the worst case scenario:
+		// 1 for a possible escape, 1 for the value and 1 to end the PPP stream.
+		if(pos >= (sizeof(wbuf) - 4)) {
+			if(DEBUG)
+				log(LOG_CRIT, "%s: rx packet is too big after PPP encoding (size %u, max is %u)\n", 
+						        __FUNCTION__, buf->len, MAX_RECV_SIZE);
+			return -EINVAL;
+		}
         e = *((char *) buf->start + x);
         if ((e < 0x20) || (e == PPP_ESCAPE) || (e == PPP_FLAG))
         {
---------------------------------------------

but I think someone from net-dialup should investigate the Debian diff further and see what can be done.
Comment 3 Kurt Lieber (RETIRED) gentoo-dev 2004-07-16 07:28:40 UTC
sent email directly to lanius and ferringb (members of the net-dialup herd)

will mask in portage if no action in 48 hours.
Comment 4 Heinrich Wendel (RETIRED) gentoo-dev 2004-07-20 10:23:53 UTC
added patch to -r2 and marked stable on x86
Comment 5 Kurt Lieber (RETIRED) gentoo-dev 2004-07-22 05:09:42 UTC
glsa 200407-17
Comment 6 heritage ericsson 2023-10-16 01:19:41 UTC Comment hidden (spam)