Bug 18611

Summary: Unfortunate regression in "ping" security
Product: [Retired] Red Hat Linux Reporter: Chris Evans <chris>
Component: iputilsAssignee: Crutcher Dunnavant <crutcher>
Status: CLOSED ERRATA QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: dr, notting, pbrown
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-10-10 19:12:38 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Chris Evans 2000-10-07 17:16:14 UTC
[Note: I've marked this bug as "BETA team" only. That's the best I can do
to stop any old
dude finding this report]

Here's a copy of a mail I sent describing the sorry state of iputils
"ping". It needs a good
audit. Or you could just adopt OpenBSD's ping, porting across any new
features in
iputils ping.
...
Hi,

Show of hands please, who is shipping "ping" from iputils? The following
is relative to "iputils-20000418-6", e.g. RH7.0's version.

We had just about got the netkit ping secure, so hey we'd better regress
by all starting to ship iputils ping which seems to have been forked from
a somewhat less secure base.

Details

- Fails to drop privilege at startup after getting the raw socket

- Buffer overflow (not on stack) in pr_addr():
...
        static char buf[256];
...
                sprintf(buf, "%s (%s)", hp->h_name,
                        inet_ntoa(*(struct in_addr *)&addr));
...

AFAIK, with glibc, hp->h_name has MAXHOSTLEN of 1024


- Small buffer overflow of size "struct timeval" above output packet
buffer

- And another possible larger buffer overflow in the same area,
http://www.openbsd.org/cgi-bin/cvsweb/src/sbin/ping/ping.c?r1=1.36&r2=1.37

- Ooh, just found a URL describing the first overflow flaw
http://www.openbsd.org/cgi-bin/cvsweb/src/sbin/ping/ping.c?r1=1.3&r2=1.4

- Unreliable nul termination of buffers, e.g.
strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
(missing explicit NULL termination)

- VERY WORRYING looking stack-based overflow
http://www.openbsd.org/cgi-bin/cvsweb/src/sbin/ping/ping.c?r1=1.27&r2=1.28

- Another buffer mismanagement flaw in the same area (read off end)
http://www.openbsd.org/cgi-bin/cvsweb/src/sbin/ping/ping.c?r1=1.28&r2=1.29


Bit of an embarassment, this, really.

Cheers
Chris

Comment 1 Chris Evans 2000-10-07 21:58:30 UTC
Update! Update! Read all about it..
Turns out many of these issues are already fixed in the recently released:
iputils-ss000928.tar.gz
(RH7.0 is based off iputils-ss000418.tar.gz which to be fair was the most recent
at freeze time!)

The most recent iputils still has a couple of minor overflows, though (although
they will of course yield a raw socket to an attacker rather than full blown
access!)

Patches to most recent iputils to appear..

Comment 2 Chris Evans 2000-10-09 22:24:46 UTC
An update.. a new upstream iputils package with all known ping security bugs
will probably be out soon.
I'll update this bug with its location when it's out.

Comment 3 Chris Evans 2000-10-10 19:12:32 UTC
New version of iputils with all known ping security bugs fixed:
ftp://ftp.inr.ac.ru/ip-routing/iputils-ss001010.tar.gz

Your call as to whether to do an update or not guys. I don't think any of the
bugs can lead to root compromise. However this is only due to luck. It all
depends on how the compiler lays out the static variables in the BSS. There are
a few statics that, if overwritten, could easily lead to a compromise. In the
current x86 binary, I believe things are safe.. but.. :-)

I'd be tempted to do an update. Better safe than sorry?

Comment 4 Jeff Johnson 2000-10-10 20:20:59 UTC
Fixed in iputils-20001010-1.

Comment 5 Matt Wilson 2000-10-18 15:56:49 UTC
Making this readable by everyone, as it is referenced in our errata advisory.