Bug #95506 MySQL Router crashes if an nmap scan is run by a non-privileged user on RHEL 6
Submitted: 23 May 2019 20:41 Modified: 24 May 2019 8:03
Reporter: Michael Peoples Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Router Severity:S2 (Serious)
Version:8.0.15, 8.0.16 OS:Red Hat (6.10)
Assigned to: CPU Architecture:x86 (VMware Guest)
Tags: MySQL Router, nmap, Red Hat, rhel

[23 May 2019 20:41] Michael Peoples
Description:
Scanning a server running MySQL Router instance using the "nmap" utility with explicit port numbers will crash the MySQL Router instance if the "nmap" command is run by a non-privileged user.  

- If nmap is run without explicit port numbers (i.e. the "-p" option is not used), then the behavior is not observded.  

- If nmap is run by a root user, this behavior is not observed. 

MySQL router is running on a Red Hat Enterprise Linux 6.10 server running on a VMware host.  Nmap version   5.51 (default version for this OS) and version 6.47-1 exhibited this behavior. Nmap version 4.11 (default version for RHEL 5) did not exhibit this behavior.

The output of nmap run by either type of user is "generally" the same.  The non-privileged user does not get MAC information.

RUN AS ROOT
-----------

nmap -p3306,6447,64460,64470 XXXXXX.XXX.XXX

Starting Nmap 5.51 ( http://nmap.org ) at 2019-05-23 20:09 GMT
Nmap scan report for XXXXXXXXXXXXXXX (XXX.XXX.XXX.XXX)
Host is up (0.00053s latency).
PORT      STATE SERVICE
3306/tcp  open  mysql
6447/tcp  open  unknown
64460/tcp open  unknown
64470/tcp open  unknown
MAC Address: XXXXXXXXXXXX (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.20 seconds
-----------------------------------------------------------------

RUN AS NON-PRIVILEGED USER
--------------------------

nmap -p3306,6447,64460,64470 XXXXXX.XXX.XXX

Starting Nmap 5.51 ( http://nmap.org ) at 2019-05-23 20:11 GMT
Nmap scan report for XXXXXXXXXXXXXXX (XXX.XXX.XXX.XXX)
Host is up (0.00022s latency).
PORT      STATE SERVICE
3306/tcp  open  mysql
6447/tcp  open  unknown
64460/tcp open  unknown
64470/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds
-----------------------------------------------------------------
- MySQL Router was bootstrapped against a MySQL (5.7.26 Community edition compiled from source) InnoDB Cluster primary node running on port 4306.  

- After bootstrap, I manually modified the READ-WRITE port value from "6446" to "3306".  

- The lack of this modification does not change the behavior.

- It does not matter which of the MySQL Router bound ports is scanned, or whether they are scanned individually, or as part of list of ports.

MySQL Router log when nmap is run by non-privileged user using explicit ports
-----------------------------------------------------------------------------
2019-05-21 17:28:16 routing ERROR [7f292ffff700] routing:bpoTestLabCluster_default_rw: getpeername() failed, errno: 107
2019-05-21 17:28:16 main ERROR [7f292ffff700] plugin 'routing:bpoTestLabCluster_default_rw' start failed: routing:bpoTestLabCluster_default_rw: getpeername() failed, errno: 107
2019-05-21 17:28:16 main INFO [7f2935f5c7e0] Shutting down. Stopping all plugins.
2019-05-21 17:28:16 routing INFO [7f2934c61700] [routing:bpoTestLabCluster_default_ro] stopped
2019-05-21 17:28:16 routing INFO [7f292ebfd700] [routing:bpoTestLabCluster_default_x_rw] stopped
2019-05-21 17:28:16 routing INFO [7f292f5fe700] [routing:bpoTestLabCluster_default_x_ro] stopped
2019-05-21 17:28:16 main INFO [7f2935f5c7e0] Deinitializing all plugins.
2019-05-21 17:28:16 main INFO [7f2935f5c7e0] Unloading all plugins.
2019-05-21 17:28:16 main ERROR [7f2935f5c7e0] Error: routing:bpoTestLabCluster_default_rw: getpeername() failed, errno: 107

How to repeat:
1) Install and configure MySQL Router community edition version 8.0.15 or 8.0.16.

2) Start MySQL Router.

3) On a separate RHEL 6 server with the RHEL default nmap package installed, login as a non-privileged user and execute the following, substituting the proper FQDN of the host:

nmap -p6446 <MySQL Router Host>

Suggested fix:
I cannot suggest a fix at this time.
[24 May 2019 7:25] MySQL Verification Team
Hello Michael Peoples,

Thank you for the report and feedback.
Verified as described.

regards,
Umesh
[24 May 2019 7:44] Jan Kneschke
Posted by developer:
 
This is a duplicate of Bug#29382585.
[24 May 2019 8:03] MySQL Verification Team
Thank you Jan for the base bug details. 

Hi Michael,

This issue has been fixed internally, per internal bug change log:

*** PHOLSON  philip.olson Sat May 18 2019 02:03:45 GMT+0530 (IST)***
Fixed as of the upcoming MySQL Router 8.0.17 release, and here's the
changelog entry:

An uncaught exception was generated if a client socket was shutdown the
client peer address was retrieved.

Thank you for the bug report. 

Closure details will be published post 8.0.17 release at https://dev.mysql.com/doc/relnotes/mysql-router/en/news-8-0-17.html 

thanks,
Umesh