🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
5 messages
5 total messages Started by Innocenti Maresin Mon, 19 Jan 2004 11:27
[INN 2.4 source] history/his.c strcmp
#67708
Author: Innocenti Maresin
Date: Mon, 19 Jan 2004 11:27
50 lines
2851 bytes
Hello, all INN users and (particulary) programmers!

Ten days ago Russ Allbery posted a message news:87u137422h.fsf@windlord.stanford.edu
about a buffer overflow vulnerability in INN 2.4.0.
I'm sure that it's not a last discovery of such kind in INN 2.4 :(

When I debugged makehistory utility, get crashed (possibly due to my buggy setup),
I saw the following:

(gdb) backtrace
#0  0x40091d04 in strcmp () from /lib/libc.so.6
#1  0x0804bb03 in HISopen (path=0x0, method=0x0, flags=11) at his.c:141
#2  0x0804b757 in main (argc=134733600, argv=0xbffffe04) at makehistory.c:862
#3  0x4003549d in __libc_start_main () from /lib/libc.so.6

In history/his.c at the specified location you can see:

struct history *
HISopen(const char *path, const char *method, int flags)
{
    struct history *h;
    int i;

    for (i = 0; i < NUM_HIS_METHODS; ++i) {
        if (strcmp(method, his_methods[i].name) == 0)
            break;
    }

I.e. program performs 
a non-length-limited comparision (strcmp) of 2 unknown strings, 
and for the "method" string we even haven't a NULL pointer check!
Evidently, it's this last who gave me memory fault.

This peece of buggy code has been added to his.c since INN 2.3.2, 
the his.c file had been essentianlly altered 
and even moved from innd/ to history/ subdirectories,
but I found no author/contributor name in the file, only stale 2001 copyright
and some remarks concerning that file in global Changelog.


I tried to setup INN 2.4.0, but just downloaded 2.4.1. 
It has the same code in history/his.c :(



-- 
qq~~~~\	[ ЗА IP БЕЗ ЦЕНЗУРЫ ]
/ /\   \  [ FAQ you ] at news:local.chainik ─ rules at http://www.comtv.ru/~av95/chainik.html
\  /_/ /
 \____/
Re: [INN 2.4 source] history/his.c strcmp
#67710
Author: Jeffrey M. Vinocur
Date: Mon, 19 Jan 2004 20:40
55 lines
2972 bytes
In article <400BBF16.C7C71F15@comtv.ru>,
Innocenti Maresin  <av95@comtv.ru> wrote:
>Hello, all INN users and (particulary) programmers!

Please don't multipost to here and the inn-workers mailing list.
Just pick one.


>[...] about a buffer overflow vulnerability in INN 2.4.0.
>I'm sure that it's not a last discovery of such kind in INN 2.4 :(

Well...I'd say that all in all INN has a pretty good record.


>#0  0x40091d04 in strcmp () from /lib/libc.so.6
>#1  0x0804bb03 in HISopen (path=0x0, method=0x0, flags=11) at his.c:141
>#2  0x0804b757 in main (argc=134733600, argv=0xbffffe04) at makehistory.c:862

Yup, you did find a bug.  I suspect your configuration does not
have "hismethod" defined in inn.conf (a new parameter in recent
versions, although it should have been added for you
automatically if installed with `make update`).


>    for (i = 0; i < NUM_HIS_METHODS; ++i) {
>        if (strcmp(method, his_methods[i].name) == 0)
>            break;
>    }
>
>I.e. program performs 
>a non-length-limited comparision (strcmp) of 2 unknown strings, 

Well, they're not unknown.  They're guaranteed to be properly
terminated since they come from other parts of INN, and at some
point you have to have invariants or you end up duplicating every
safety check you've ever made.


>and for the "method" string we even haven't a NULL pointer check!
>Evidently, it's this last who gave me memory fault.

So yes, it's a bug.  But no, it's not exploitable in any way.

Russ, I still can't authenticate to CVS, can't you fix this?

There's a check in innd/util.c:InndHisOpen() for absence of
innconf->hismethod, but makehistory's call to HISopen() is not
similarly prefaced.  I'm not sure whether it's better to copy
that check into makehistory.c, or put a check in HISopen for a
NULL method being passed, or both...


-- 
Jeffrey M. Vinocur
jeff@litech.org
Re: [INN 2.4 source] history/his.c strcmp
#67711
Author: Russ Allbery
Date: Mon, 19 Jan 2004 22:21
30 lines
2233 bytes
Jeffrey M Vinocur <jeff@litech.org> writes:
> Innocenti Maresin  <av95@comtv.ru> wrote:

>>    for (i = 0; i < NUM_HIS_METHODS; ++i) {
>>        if (strcmp(method, his_methods[i].name) == 0)
>>            break;
>>    }

>> I.e. program performs 
>> a non-length-limited comparision (strcmp) of 2 unknown strings, 

strcmp is perfectly safe if the strings you're working with are guaranteed
to be nul-terminated, regardless of how long they are.  In this particular
case, you're getting a segfault because one of the strings is NULL, not
because of any sort of overflow.  This is a bug, but is not exploitable
regardless of the source of the string (and in this case, since it's
coming from your local configuration, it's obviously also not exploitable
because of that).

I'll improve the error message.  :)

> Russ, I still can't authenticate to CVS, can't you fix this?

Yup.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: [INN 2.4 source] history/his.c strcmp
#67716
Author: Jeffrey M. Vinocur
Date: Mon, 19 Jan 2004 23:35
26 lines
2192 bytes
In article <87isj7y3zj.fsf@windlord.stanford.edu>,
Russ Allbery  <rra@stanford.edu> wrote:
>
>strcmp is perfectly safe if the strings you're working with are guaranteed
>to be nul-terminated, regardless of how long they are.  In this particular
>case, you're getting a segfault because one of the strings is NULL, not
>because of any sort of overflow.  This is a bug, but is not exploitable
>regardless of the source of the string (and in this case, since it's
>coming from your local configuration, it's obviously also not exploitable
>because of that).

And in fact, it's not even exploitable by way of the local
configuration -- no matter what you put in inn.conf, the char* is
still going to end up properly terminated.  

Not that it matters in this case, of course.  We're not trying to
protect INN from users who have write access to the config files.

(...and besides, strcmp isn't strcpy; even if you get strcmp to
run off the end of a string, it's only ever going to be a denial
of service.)


-- 
Jeffrey M. Vinocur
jeff@litech.org
Re: [INN 2.4 source] history/his.c strcmp
#67767
Author: Russ Allbery
Date: Mon, 26 Jan 2004 02:20
19 lines
1940 bytes
Jeffrey M Vinocur <jeff@litech.org> writes:

> Russ, I still can't authenticate to CVS, can't you fix this?

> There's a check in innd/util.c:InndHisOpen() for absence of
> innconf->hismethod, but makehistory's call to HISopen() is not
> similarly prefaced.  I'm not sure whether it's better to copy
> that check into makehistory.c, or put a check in HISopen for a
> NULL method being passed, or both...

I went ahead and added a check to the inn.conf parser to ensure that
hismethod is set there, since that's what was done with ovmethod and
HISopen is called all over the place.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads