[MIR] mysql-router (mysql-8.0)

Bug #1852367 reported by Rafael David Tinoco
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mysql-8.0 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

[Availability]

All mysql-server-8 binary packages are already in main, but mysql-router, mysql-testsuite and mysql-source-8. From those, mysql-router should be in main judging its importance to mysql setups:

upstream:

 - https://github.com/mysql/mysql-server/tree/8.0/router

rmadison:

  mysql-router | 8.0.17-0ubuntu2 | eoan/universe
  amd64, arm64, armhf, i386, ppc64el, s390x

  mysql-router | 8.0.17-0ubuntu3 | focal/universe
  amd64, arm64, armhf, i386, ppc64el, s390x

There are juju charms already relying on it:

https://github.com/openstack/charm-mysql-router/tree/master/src

being actively developed.

[Rationale]

Before mysql-server-8, mysql-router wasn't part of the upstream mysql-server source. It got included from commit:

commit 07f77542cb3
Author: Andrzej Religa <email address hidden>
Date: Fri Aug 10 13:45:46 2018

    wl#10799 integrate MySQL Router into MySQL Server repository

describe: mysql-8.0.12-77027-g07f77542cb3

Before that the last available mysql-router was:

(mysql-router-2.1.6.tar.gz)

distributed apart from the main mysql-server code.

[Security]

Couldn't find any cve specific to mysql-router in:

  - cve.mitre.org (only mysql-server CVEs)
  - www.openwall.com (only mysql-server CVEs)

- binaries

  usr/bin/mysqlrouter_plugin_info
  usr/bin/mysqlrouter
  usr/bin/mysqlrouter_passwd

- no suid/sgid bits
- no services

- mysql-router default ports:

  6446/tcp 6447/tcp 3306/tcp 6448/tcp 6449/tcp 33060/tcp

  https://dev.mysql.com/doc/mysql-port-reference/en/
  mysql-ports-reference-tables.html

[Quality assurance]

- source as mysql-server-8, binary is still in universe
- possible to config based on documentation
- do not ask debconf questions by default
- no long-term outstanding bugs (mysql behind)
- important bugs / upstream supportability:
- ubuntu pushing new debian mysql-server pkgs (tks to @rbasak).
- mysql-server-8 is already in main
- contains tests: <source>/router/tests
- uses debian/watch
- does not rely on obsolete packages
- no exotic hardware

bugs since it was G/A (2018-04-19)

https://dev.mysql.com/doc/relnotes/mysql-router/en/news-8-0-x.html

All MySQL Router BUGS in upstream community:
(ordered by version, only 8.0.xx matter, as they were GA)

https://tinyurl.com/vvkx46q

[UI standards]

N/A

[Dependencies]

    pool/main/g/glibc/libc6_2.30-0ubuntu2_amd64.deb
    pool/main/libe/libevent/libevent-core-2.1-7_2.1.11-stable-1_amd64.deb
    pool/main/libe/libevent/libevent-extra-2.1-7_2.1.11-stable-1_amd64.deb
    pool/main/g/gcc-9/libgcc1_9.2.1-19ubuntu1_amd64.deb
    pool/main/g/gcc-9/libgcc-9-dev_9.2.1-19ubuntu1_amd64.deb
    pool/main/o/openssl/libssl1.1_1.1.1c-1ubuntu4_amd64.deb
    pool/main/g/gcc-9/libstdc++6_9.2.1-19ubuntu1_amd64.deb
    pool/main/z/zlib/zlib1g_1.2.11.dfsg-1ubuntu3_amd64.deb

- recommends:

    pool/main/libi/libidn2/libidn2-0_2.2.0-2_amd64.deb
    pool/main/g/glibc/libc6-dev_2.30-0ubuntu2_amd64.deb

All dependencies are in main.

[Standards compliance]

- Meets FHC (https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard)
- Same Debian policy standards are mysql-server.

[Maintenance]

- well maintained in Debian/Ubuntu
  (will be maintained with mysql-server-8)

- ubuntu-server will subscribe for package maintenance

[Background information]

MySQL Router is lightweight middleware that provides transparent routing between your application and any backend MySQL Servers. It can be used for a wide variety of use cases, such as providing high availability and scalability by effectively routing database traffic to appropriate backend MySQL Servers. The pluggable architecture also enables developers to extend MySQL Router for custom use cases.

Failover

Typically, a highly available MySQL setup consists of a single master and multiple slaves and it is up to the application to handle failover, in case the MySQL master becomes unavailable. Using MySQL Router, application connections will be transparently routed based on load balancing policy, without implementing custom application code.

Load Balancing

MySQL Router provides additional scalability and performance by distributing database connections across a pool of servers. For example, if you have a replicated set of MySQL Servers, MySQL Router can distribute application connections to them in a round-robin fashion.

description: updated
Changed in mysql-8.0 (Ubuntu):
milestone: none → ubuntu-20.04
Changed in mysql-8.0 (Ubuntu):
assignee: nobody → Christian Ehrhardt  (paelzer)
description: updated
description: updated
description: updated
description: updated
description: updated
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Download full text (4.0 KiB)

[Summary]
- MIR Team ack
- needs no subscriber as it is part of mysql-8 which has the server Team subscribed already
@Security
- Security check of the subdir router/* requested
@Server
- While security is working on the review the server Team should try to enable the tests in router/test/* in either build or autopkgtest
- should we add a service file or something or is this intentionally up to the users and/or the mentioned charms thereof?
- d/copyright could get an update lintian yells about it all over the place

[Background]
This is the request to review a new binary of a package otherwise already in main.
But since the functionality wasn't in the source long ago when it was accepted and since functionally it is rather (security) critical a re-review was requested.
Going forward it is important to understand that we are not (re-)reviewing all of mysql but the subdir router/* and its associated snippets in the build system and debian directory.

[Duplication]
There is no other package that provides the function of mysql-router.
There are other DB-proxies like postgresql-12-pgpool2 mariadb maxscale, ... there is none for mysql yet and none in main.

[Embedded sources and static linking]
- no embedded libs
- no golang

[Security]
- no history of CVEs
- does not use webkit1,2
- does not use lib*v8 directly
- does not processe arbitrary web content
- does not use centralized online accounts
- does not integrate arbitrary javascript into the desktop
- does not deal with system authentication (eg, pam), etc)

Ok, but worth to look at:
- while it does not run a daemon as root (we only provide the binary, no service)
  That still means for deployment people will have to use it in such a way or similar
  => https://dev.mysql.com/doc/mysql-router/8.0/en/mysql-router-general-using-deploying.html
- while only redirecting instead of handling the requests it does parses data formats
- it opens a port or sockets depending on setup
- technically a proxy is itself a "man in the middle" so attacks like that get more attack surface to work with

While being under the same strict coverage like mysql8 itself being part of the same source feels good I think this is worth a check by the security Team.

[Common blockers]
- builds fine atm
- already has a bug subscriber
- translations are not present (for this componentn) but it isn't user facing
- not a python package, so no further checks on that needed

Not perfect, but acceptable for now:
- router has an own test section in the code at router/tests
  But I see none of them run at build or autopkgtest time:
  => https://launchpadlibrarian.net/452198941/buildlog_ubuntu-focal-amd64.mysql-8.0_8.0.18-0ubuntu3_BUILDING.txt.gz
  => https://objectstorage.prodstack4-5.canonical.com/v1/AUTH_77e2ada1e7a84929a74ba3b87153c0ac/autopkgtest-focal/focal/amd64/m/mysql-8.0/20191119_213042_010c3@/log.gz
  Adding that would be great for QA

[Packaging red flags]
- Ubuntu carries delta in general but nothing massive and nothing on router
- it has a bunch of "internal" libs in /usr/lib/mysql-router/ not meant for external usage.
  While tracking symbols is nice in this case it isn't strictly required
  Also once bug 1845661 is fixed ...

Read more...

Changed in mysql-8.0 (Ubuntu):
assignee: Christian Ehrhardt  (paelzer) → Ubuntu Security Team (ubuntu-security)
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

TODOs for me:

- enable tests from router/test/* in either build or autopkgtest -> for QA and regressions.
- check if service is needed (based on charm usage as well).
- d/copyright changes so lintian is satisfied.

Rest is with security team I guess. Thanks a lot for reviewing this @paelzer.

Changed in mysql-8.0 (Ubuntu):
assignee: Ubuntu Security Team (ubuntu-security) → nobody
assignee: nobody → Ubuntu Security Team (ubuntu-security)
Revision history for this message
Eduardo Barretto (ebarretto) wrote :
Download full text (5.5 KiB)

I reviewed mysql-router 8.0.19-0ubuntu2 as checked into focal (when this review
started). This shouldn't be considered a full audit but rather a quick gauge of
maintainability.

mysql-router is a binary package from mysql-8.0 that is responsible for routing
connections from MySQL clients to MySQL servers. As mentioned previously, only
mysql-router is missing in main from mysql-8.0 source package.

- No CVE History:
- Build-Depends
  - libc6 (>= 2.28)
  - libevent-core-2.1-7 (>= 2.1.8-stable)
  - libevent-extra-2.7-7 (>= 2.1.8-stable)
  - libevent-openssl-2.7-7 (>= 2.1.8-stable)
  - libgcc1
  - liblz4-1
  - libssl1.1
  - libstdc++6
  - zlib1g
- No pre/post rm and pre/post inst scripts.
- No init scripts
- No systemd units
- No dbus services
- No setuid binaries
- binaries in PATH
  - /usr/bin/mysqlrouter
  - /usr/bin/mysqlrouter_keyring
  - /usr/bin/mysqlrouter_passwd
  - /usr/bin/mysqlrouter_plugin_info
- No sudo fragments
- No polkit files
- No udev rules
- unit tests / autopkgtests
  - As mentioned previously, router has its own test section in the code at
    router/tests, but it's not available during build or in autopkgtest.
- No cron jobs
- Build logs:
  - Apparently no relevant issues on router build log.

- Processes spawned
  - Some bash scripts are created on router. We don't like the sudo commands but
    it looks unlikely to be used in an automated way:
    - router/src/router/src/config_generator.cc:2781
  - router/src/http/src/posix_re.h:173: Posix extended regular expressions.
     C++11 has std::regex, by gcc-4.x throws exceptions when it it used. Instead
     mysql-router implements a subset of std::regex. It looks like they didn't
     try to recreate the wheel on this, so looks fine.
  - router/src/harness/src/utilities-posix.cc:49
  - router/src/harness/src/process_launcher.cc:448
  - router/src/harness/src/hostname_validator.cc:51
  - All above look fine
- Memory management
  - Lots of memory management, hard to say just by looking if anything is
    wrong, so will dig into it during cppcheck.
- File IO
  - Lots of file IO, but looks ok.
- Logging
  - router/src/json_schema_embedder/json_schema_embedder.cc: logs to in_filename
    and out_filename that the user passed as argument.
  - the rest of the code seems to be covered by mysql-router logging feature
    e.g.: https://dev.mysql.com/doc/mysql-router/8.0/en/mysql-router-server-logging.html
- Environment variable usage
  - router uses some environment variables in its tests.
  - other than that:
   - router/src/router/src/router_app.cc:117: std::string path(std::getenv("PATH"));
   - router/src/router/src/router_app.cc:585: auto pid_file_env = std::getenv("ROUTER_PID");
   - router/src/router/src/config_generator.cc:1761: std::string path(std::getenv("PATH"));
   - router/src/router/src/common/mysql_session.cc:290: getenv("MYSQL_ROUTER_RECORD_MOCK") ? getenv("MYSQL_ROUTER_RECORD_MOCK")
   - router/src/router/src/common/mysql_session.cc:297: const char *outfile = std::getenv("MYSQL_ROUTER_RECORD_MOCK");
   - router/src/router/src/keyring_info.cc:179: err_code = ::setenv("ROUTER_ID", std::to_string(router_id).c_str(), 1);
   - router/src/router/src/utils.c...

Read more...

Changed in mysql-8.0 (Ubuntu):
assignee: Ubuntu Security Team (ubuntu-security) → nobody
Steve Beattie (sbeattie)
Changed in mysql-8.0 (Ubuntu):
status: New → Confirmed
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

This is ready, all it needs are the tasks mentioned in
   https://bugs.launchpad.net/ubuntu/+source/mysql-8.0/+bug/1852367/comments/2
to be resolved.

Other than that this would be ready for promotion to main.

Changed in mysql-8.0 (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

There has been not further update for too long, for now we consider it invalid.
Feel free to re-open if there is effort backing it up and motivation to bring it to main.

Changed in mysql-8.0 (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.