Home page logo
/

bugtraq logo Bugtraq mailing list archives

Re: efingerd remote buffer overflow and a dangerous feature
From: Michael Bacarella <mbac () netgraft com>
Date: Wed, 6 Mar 2002 12:38:56 -0600

While I haven't viewed the code to efingerd, the author does
claim that it is based (indirectly) on ident2. I went through
great pains to make sure ident2 was secure which is why I feel
that I should comment.

ident2 is a pretty minimal, allegedly secure daemon which implements the
auth protocol.  Unless the sys admin has a special need, I highly recommend
that ident2 is run with the -r option which generates a pseudo-random reply
(and leaks no information about which server processes run as which users).

Commenting on Spybreak's individual points:

On Wed, Mar 06, 2002 at 10:17:31AM +0100, Spybreak wrote:
1.) Remote buffer overflow

In the stable version it is possible to remotely cause a buffer overflow
condition
through an exploitation of a reverse-lookup part of the code:


static char *lookup_addr (struct in_addr in)
{
        static char addr[100];
        struct hostent *he;

        if (resolve_addr) {
                he = gethostbyaddr ((char *)&in, sizeof(struct
in_addr),AF_INET);
                if (he == NULL)
                        strcpy(addr, inet_ntoa(in));
                else
                        strcpy(addr, he->h_name);
        }
        else
                strcpy (addr, inet_ntoa (in));

        return addr;
}

Ident2 is not vulnerable to this exploit.

The code simply doesn't exist in ident2.
 
Usually efingerd runs as 'nobody'.

2.) The feature

But there is another security issue with efingerd (in both versions).
When some existing user is fingered, efingerd looks for a ".efingerd" file
in that user's home directory and if it does exist and it is executable it
tries to execute it - as 'nobody'. The .efingerd's output is sent back to
the fingerer.

So _whatever_ a local user puts in his .efingerd file, can be executed under
nobody UID/GID simply by fingering himself. So getting a nobody/nobody shell
is straighforward.
This can be very interesting for a potential evildoer going to hide his
identity during some nasty actions, for example local DoS attacks.
As the logfile is writable by the UID of efingerd, it can be easily
manipulated.

This feature can be turned off with the -u option.

Ident2 has a similar feature, but is not vulnerable to this attack.

If the -i option has been specified, and the file .ident exists in
the user's home directory, ident2 will substitute the user's supplied
ident. Under no circumstance will it attempt to execute the file.

The user specified reply will also be ignored unless it's
preceded by "ident ".

-- 
Michael Bacarella              | 545 Eighth Ave #401
                               | New York, NY 10018
Systems Analysis & Support     | mike () bacarella com
Managed Services               | 212 946-1038


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]