🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #22293

Re: More luser "long newgroup's" issued

#22293
From: Doug Ledford
Date: Sun, 12 Oct 1997 00:00
73 lines
4352 bytes
Chris Caputo (ccaputo@alt.net) wrote:
: jgreco@ns.sol.net (Joe Greco) writes:
: >Some luser at Sympatico is issuing newgroup's to crash INN.
: >Data at http://www.nntp.sol.net/wanker

: I couldn't get to your page, but here's a patch for the bug.  Best to
: apply manually since it is intended for multiple versions of INN.

While applying this patch manually to inn-1.6b3, I think I've found a
more general (and problematic) error in programming.  The patch should
fix the problem of overrunning the active.times buffer space, but does
nothing for the actual ICDnewgroup call.  As it turns out, there is an
error there as well, and if it (as I suspect) is prevelant throughout
the inn-1.6b3 sources, repairs of this error will take some time.  Let
me expound a bit, take the following code snippet from icd.c:

    char                buff[SMBUF];
    IOVEC               iov[2];
    BOOL                ret;

    /* Set up the scatter/gather vectors. */
    if (strlen(Name) + strlen(Rest) > (SIZE_T)(SMBUF - 24)) {
        syslog(L_ERROR, "%s too_long %s", LogName, MaxLength(Name, Name));
        return FALSE;
    }
    (void)snprintf(buff, sizeof(buff),
                "%s 0000000000 0000000001 %s\n", Name, Rest);
    ICDiovset(&iov[0], ICDactpointer, ICDactsize);
    ICDiovset(&iov[1], buff, strlen(buff));

    ret = ICDwritevactive(iov, 2);
    ICDiovrelease(&iov[0]);
    ICDiovrelease(&iov[1]);
    return ret;

There are two key things to note here.  First, the check for strlen(Name) +
strlen(Rest) being > SMBUF - 24.  Second, note that the number of characters
added to those two strings during the snprintf() statement counts out to
exactly 24.  This means that if strlen(Name) + strlen(Rest) == SMBUF - 24,
then the test fails, we perform the snprintf (with no buffer overflow as
intended), then we proceed further on.  However, since the number of
characters added was 24, and SMBUF only had 24 characters to spare, we end
up with no NULL terminator.  Not so bad, until two lines later when we
set an IOVEC based upon strlen(buff).  Without the NULL terminator, and
having already done an iovset on iov[0], we are gauranteed that the strlen
will return a value larger than SMBUF.  We are then gauranteed to corrupt
our active file.  Nice.

Depending on how prevelant this type of error is in 1.6b3, there are a
large number of ways a person could corrupt files and crash servers by
simply doing something like a newgroup with a group name of SMBUF - 25
bytes and a single char Rest.  With a standard SMBUF of 256 bytes then,
a newgroup of 231 characters plus the y flag would result in a corrupted
active file.

Now, since the concept of snprintf(buff, sizeof(buff)...) followed by a
strlen(buff) is common (and needed in order to keep the strings from
always being SMBUF or whatever length in size), then a person must take
care to ensure that the buff is always NULL terminated or the strlen()
can have some very unwanted side effects.

--
*****************************************************************************
* Doug Ledford                      *   Unix, Novell, Dos, Windows 3.x,     *
* dledford@dialnet.net    873-DIAL  *     WfW, Windows 95 & NT Technician   *
*   PPP access $14.95/month         *****************************************
*   Springfield, MO and surrounding * Usenet news, e-mail and shell account.*
*   communities.  Sign-up online at * Web page creation and hosting, other  *
*   873-9000 V.34                   * services available, call for info.    *
*****************************************************************************

Technical Details
Message-ID: <61r9cm$vhb$1@news.dialnet.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <61jna5$1jv$1@earth.execpc.com> <61jp17$db8$0@207.14.113.2>

Show Full Headers
Complete Article Headers
Message-ID: <61r9cm$vhb$1@news.dialnet.net>
Subject: Re: More luser "long newgroup's" issued
Date: Sun, 12 Oct 1997 00:00:00 +0000
From: dledford@news.dialnet.net (Doug Ledford)
References: <61jna5$1jv$1@earth.execpc.com> <61jp17$db8$0@207.14.113.2>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 279845270
X-Complaints-To: news@news.dialnet.net
X-Trace: news.dialnet.net 876685526 32299 (None) 206.65.248.4
Organization: DialNet USENET News Service.
Newsgroups: news.software.nntp