Article View: news.software.nntp
Article #19607Re: ANNOUNCE: INN 1.5.1 buffer overflow patch
From: Miquel van Smoorenburg
Date: Thu, 24 Jul 1997 00:00
Date: Thu, 24 Jul 1997 00:00
64 lines
3043 bytes
3043 bytes
In article <5r8944$7d3$1@news1.epix.net>,
Forrest J. Cavalier III <mibsoft@epix.net> wrote:
>
>In article <5r81l9$27j$1@holodeck.cistron.nl>, miquels@cistron.nl wrote...
> 6. String Limit defect fixes which are in themselves defective.
>
>As an example of category number 6, there is code in innd/cc.c CCmode()
>
>#ifndef INN1P6SD
> p += strlen(strcpy(p, "running"));
>#else /* INN1P6SD */
> p += strlen(strncpy(p, "running", sizeof(buff) - strlen(buff) - 1));
> buff[sizeof(buff) - 1] = '\0';
>#endif /* INN1P6SD */
>
>This is a basic mistake: You can't strlen a strncpy result. The null
>terminating assignment happens too late. (This is actually in a place
>where p is KNOWN to be large enough, so this new bug is latent or
>untriggerable.)
However, most recent strncpy()s DO add a \0 to the end of the string if
there's space left (SVID 3, POSIX, BSD 4.3, ISO 9899). From my manpage:
In the case where the length of src is less than that of
n, the remainder of dest will be padded with nulls.
So I think that
strncpy(p, "running", sizeof(buff) - strlen(buff) - 1)
does indeed put a \0 at the end of the string and the
buff[sizeof(buff) - 1] = '\0';
is superfluous.
>Still, this indicates to me that not enough time was spent approving
>the new changes.
Who says that all holes have been fixed in 1.6beta. It's useless to
diff 1.5.1 and 1.6.b2 and backport the security fixes. You have to
independently review 1.5.1, and fix it. At a later date the code needs
to be put in 1.6b2 and the result as a whole needs to be checked again.
I plugged all obvious holes in my patch, but note that I did not fix ALL
sprintf()s and strcpy()s. The only ones that need to be fixed are those
that depend on variable input or better, user input. I wish C had something
like perl tainting (and limitless strings :))
>BTW, the appropriate change would have been:
> buff[sizeof(buff) - 1] = '\0';
> p += strlen(strncpy(p, "running", sizeof(buff) - strlen(buff) - 2));
^^^
That should be -1.
Mike.
--
| Miquel van Smoorenburg | "I need more space" "Well, why not move to Texas" |
| miquels@cistron.nl | "No, on my account, stupid." "Stupid? Uh-oh.." |
| PGP fingerprint: FE 66 52 4F CD 59 A5 36 7F 39 8B 20 F1 D6 74 02 |
Technical Details
Message-ID:
<5r8a6h$30f$1@holodeck.cistron.nl>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-mailReferences:
<5r81l9$27j$1@holodeck.cistron.nl> <5r8944$7d3$1@news1.epix.net>Show Full Headers
Complete Article Headers
Message-ID: <5r8a6h$30f$1@holodeck.cistron.nl> Subject: Re: ANNOUNCE: INN 1.5.1 buffer overflow patch Date: Thu, 24 Jul 1997 00:00:00 +0000 From: miquels@cistron.nl (Miquel van Smoorenburg) References: <5r81l9$27j$1@holodeck.cistron.nl> <5r8944$7d3$1@news1.epix.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 X-Deja-AN: 258556284 Organization: Cistron Internet Services B.V. X-Server-Date: 24 Jul 1997 19:24:55 GMT Newsgroups: news.software.nntp