Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1637567

Summary: rpcinfo: Fix stack buffer overflow
Product: Red Hat Enterprise Linux 7 Reporter: Steve Dickson <steved>
Component: rpcbindAssignee: Steve Dickson <steved>
Status: CLOSED ERRATA QA Contact: Yongcheng Yang <yoyang>
Severity: unspecified Docs Contact:
Priority: high    
Version: 7.7CC: extras-qa, rhandlin, steved, xzhou, yoyang
Target Milestone: rcKeywords: Patch, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rpcbind-0.2.0-48.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1637562
: 1668668 (view as bug list) Environment:
Last Closed: 2019-08-06 13:17:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1637562    
Bug Blocks: 1637565, 1668668    

Description Steve Dickson 2018-10-09 13:44:03 UTC
+++ This bug was initially created as a clone of Bug #1637562 +++

Description of problem:



Function rpcbdump from the rpcbind binary contains a fixed sized
buffer for the netid:

static void
rpcbdump (dumptype, netid, argc, argv)
     int dumptype;
     char *netid;
     int argc;
     char **argv;
{
...
  char buf[256];
...

which is later filled via:

  for (nl = rs->nlist; nl; nl = nl->next)
            {
              strcat (buf, nl->netid);
              if (nl->next)
                strcat (buf, ",");
            }

This is vulnerable to buffer overflows.
After crafting an malicious rpcbind server by tweaking its
initialization with gdb:

(gdb)
840             rbl->rpcb_next = list_rbl;      /* Attach to global list */
(gdb) python
> gdb.execute('set rbl->rpcb_map.r_netid="'+256*'a'+'"')
> end
(gdb)  print rbl->rpcb_map.r_netid
$1 = 0x555555763d80 'a' <repeats 200 times>...
(gdb) continue
Continuing.
Continuing.
I can trigger an overflow and abort thanks to the FORTIFY_SOURCE
protection of strcat at the remote client side when it requests info:

   program version(s) netid(s)                         service     owner
*** buffer overflow detected ***: rpcinfo terminated
======= Backtrace: =========
/lib64/libc.so.6(+0x721af)[0x7ff24c4451af]
/lib64/libc.so.6(__fortify_fail+0x37)[0x7ff24c4ccdc7]
/lib64/libc.so.6(+0xf8050)[0x7ff24c4cb050]
rpcinfo(+0x435f)[0xef3be2635f]
rpcinfo(+0x1c62)[0xef3be23c62]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7ff24c3f36e5]
rpcinfo(+0x2739)[0xef3be24739]
======= Memory map: ========


Version-Release number of selected component (if applicable):


How reproducible:
100% 




Additional info:

Upstream Commit

commit 0bc1c0ae7ce61a7ac8a8e9a9b2086268f011abf0 
Author: Steve Dickson <steved>
Date:   Tue Oct 9 09:19:50 2018 -0400

    rpcinfo: Fix stack buffer overflow

Comment 8 Yongcheng Yang 2019-05-21 01:58:27 UTC
Have verified the rpcbind-0.2.0-48.el7 using tool gdb.

[root ~]# ps aux | grep -v grep | grep rpcbind
[root ~]# gdb rpcbind -w -f
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-115.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/sbin/rpcbind...Reading symbols from /usr/lib/debug/usr/sbin/rpcbind.debug...done.
done.
(gdb) break 802
Breakpoint 1 at 0x7e71: file src/rpcbind.c, line 802.
(gdb) r
Starting program: /usr/sbin/rpcbind 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 1, rbllist_add (vers=3, nconf=0x5555557639a0, addr=0x7fffffffde50, prog=100000) at src/rpcbind.c:802
/usr/src/debug/rpcbind-0.2.0/src/rpcbind.c:802:20898:beg:0x55555555be71
(gdb) print rbl->rpcb_map.r_netid
$1 = 0x555555765a70 "local"
(gdb) python
>gdb.execute('set rbl->rpcb_map.r_netid="'+256*'a'+'"')
>end
(gdb) print rbl->rpcb_map.r_netid
$2 = 0x555555765b40 'a' <repeats 200 times>...
(gdb) c
Continuing.
...

Breakpoint 1, rbllist_add (vers=4, nconf=0x555555772ca0, addr=0x7fffffffde50, prog=100000) at src/rpcbind.c:802
/usr/src/debug/rpcbind-0.2.0/src/rpcbind.c:802:20898:beg:0x55555555be71
(gdb) c
Continuing.
Detaching after fork from child process 4138.
[Inferior 1 (process 4095) exited normally]
(gdb) q
[root ~]# ps aux | grep -v grep | grep rpcbind
rpc       4138  0.3  0.0  69276  1436 ?        Ss   21:54   0:00 /usr/sbin/rpcbind
[root ~]# rpcinfo -s
   program version(s) netid(s)                         service     owner
    100000  2,3,4     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa portmapper  superuser
[root ~]# echo $?
0
[root ~]# rpm -q rpcbind
rpcbind-0.2.0-48.el7.x86_64
[root ~]#

Comment 11 errata-xmlrpc 2019-08-06 13:17:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:2311