Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 78371 - net-misc/netkit-rwho: rwhod DoS (CAN-2004-1180)
Summary: net-misc/netkit-rwho: rwhod DoS (CAN-2004-1180)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: High minor (vote)
Assignee: Gentoo Security
URL: http://www.novell.com/linux/download/...
Whiteboard: B3 [noglsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-17 08:02 UTC by Thierry Carrez (RETIRED)
Modified: 2005-02-06 11:11 UTC (History)
0 users

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 Thierry Carrez (RETIRED) gentoo-dev 2005-01-17 08:02:26 UTC
From Vlad902:

I've found that a DoS vulnerability exists in the netkit-rwhod
package. rwhod starts two processes, one to listen for connections and
another to broadcast messages. It is possible to remotely crash the
listener; it is not possible to exploit this vulnerability to execute
arbitary code. This vulnerability only occurs on little endian
computers because rwhod trusts external input. The anomaly exists in
the following code (rwhod.c):

                cc = recvfrom(sk, (char *)&wd, sizeof(struct whod), 0,
                              (struct sockaddr *)&from, &len);
                if (cc <= 0) {
                        if (cc < 0 && errno != EINTR)
                                syslog(LOG_WARNING, "recv: %m");
                        continue;
                }

... Some checks here ...

#if ENDIAN != BIG_ENDIAN
                {
                        int i, n = (cc - WHDRSIZE)/sizeof(struct whoent);
                        struct whoent *we;

                        /* undo header byte swapping before writing to file */
                        wd.wd_sendtime = ntohl(wd.wd_sendtime);
                        for (i = 0; i < 3; i++)
                                wd.wd_loadav[i] = ntohl(wd.wd_loadav[i]);
                        wd.wd_boottime = ntohl(wd.wd_boottime);
                        we = wd.wd_we;
                        for (i = 0; i < n; i++) {
                                we->we_idle = ntohl(we->we_idle);
                                we->we_utmp.out_time =
                                    ntohl(we->we_utmp.out_time);
                                we++;
                        }
                }
#endif

rwhod trusts that the other host sent a packet that is at least of
size WHDRSIZE, otherwise the integer will roll over to a negative
number, then when the division occurs it will become a very large
positive integer causing the second for loop to loop until it reaches
the end of the stack. When it reaches the end of the stack it will
fault and cause an effective DoS on the listener. A simple "exploit"
for this vulnerability would be to send a valid packet of size
WHDRSIZE-1. This would cause the receiver to not function any longer.
A simple fix for this vulnerability would be to add a check on the
'cc' variable directly after the recvfrom() call (rwhod.c:253).

=====================================================================
diff -u netkit-rwho-0.17/rwhod/rwhod.c netkit-rwho-0.17/rwhod/rwhod.c
--- netkit-rwho-0.17/rwhod/rwhod.c
+++ netkit-rwho-0.17/rwhod/rwhod.c
@@ -314,6 +314,8 @@
 				syslog(LOG_WARNING, "recv: %m");
 			continue;
 		}
+		if (cc < WHDRSIZE)
+			continue;
 		if (from.sin_port != sp->s_port) {
 			syslog(LOG_WARNING, "%d: bad from port",
 				ntohs(from.sin_port));
====================================================================
Comment 1 Thierry Carrez (RETIRED) gentoo-dev 2005-01-24 05:58:55 UTC
Attached patch applies to our source :

patching file netkit-rwho-0.17/rwhod/rwhod.c
Hunk #1 succeeded at 258 (offset -56 lines).

Waiting for a disclosure date.
Comment 2 Thierry Carrez (RETIRED) gentoo-dev 2005-02-04 03:06:56 UTC
Apparently public and patched by SuSE (see URL)

solar/vapier: this is noherd so you'll probably have to patch it on security behalf.
Comment 3 SpanKY gentoo-dev 2005-02-04 22:46:18 UTC
added the proposed fix along with a syslog(warning) when such a condition is met

marked stable for all arches who care, 0.17-r1 now in portage
Comment 4 Thierry Carrez (RETIRED) gentoo-dev 2005-02-06 09:17:29 UTC
GLSA vote... I vote no. Who cares about rwho anyway ?
Comment 5 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2005-02-06 11:11:06 UTC
I vote for no GLSA as well.