Bug 1839827 (CVE-2020-13249) - CVE-2020-13249 mariadb-connector-c: Improper validation of content in a OK packet received from server
Summary: CVE-2020-13249 mariadb-connector-c: Improper validation of content in a OK pa...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2020-13249
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1839828 1841915 1841916 1841917 1841918 1843795 1843796 1843797 1880332 1894126 1899069 1899070 1899071 1899072 1899073 1899074 1899075 1899076
Blocks: 1839829
TreeView+ depends on / blocked
 
Reported: 2020-05-25 16:53 UTC by Pedro Sampaio
Modified: 2024-03-25 15:58 UTC (History)
21 users (show)

Fixed In Version: mariadb-connector-c 3.1.8, mariadb 10.4.13, mariadb 10.3.23, mariadb 10.2.32
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-10-05 20:21:12 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:5318 0 None None None 2020-12-02 11:08:04 UTC
Red Hat Product Errata RHBA-2021:0025 0 None None None 2021-01-05 14:20:49 UTC
Red Hat Product Errata RHSA-2020:4174 0 None None None 2020-10-05 15:15:56 UTC
Red Hat Product Errata RHSA-2020:5246 0 None None None 2020-11-30 13:44:59 UTC
Red Hat Product Errata RHSA-2020:5500 0 None None None 2020-12-15 17:10:27 UTC
Red Hat Product Errata RHSA-2020:5503 0 None None None 2020-12-15 17:11:21 UTC
Red Hat Product Errata RHSA-2020:5654 0 None None None 2020-12-22 09:01:54 UTC
Red Hat Product Errata RHSA-2020:5655 0 None None None 2020-12-22 09:07:30 UTC
Red Hat Product Errata RHSA-2020:5660 0 None None None 2020-12-22 09:15:54 UTC
Red Hat Product Errata RHSA-2020:5662 0 None None None 2020-12-22 09:28:00 UTC
Red Hat Product Errata RHSA-2020:5663 0 None None None 2020-12-22 09:24:48 UTC
Red Hat Product Errata RHSA-2020:5665 0 None None None 2020-12-22 09:26:00 UTC

Description Pedro Sampaio 2020-05-25 16:53:50 UTC
libmariadb/mariadb_lib.c in MariaDB Connector/C before 3.1.8 does not properly validate the content of an OK packet received from a client. NOTE: although mariadb_lib.c was originally based on code shipped for MySQL, this issue does not affect any MySQL components supported by Oracle.

Upstream fix:

https://github.com/mariadb-corporation/mariadb-connector-c/commit/2759b87d72926b7c9b5426437a7c8dd15ff57945
https://github.com/mariadb-corporation/mariadb-connector-c/compare/v3.1.7...v3.1.8

Comment 1 Pedro Sampaio 2020-05-25 16:54:13 UTC
Created mariadb-connector-c tracking bugs for this issue:

Affects: fedora-all [bug 1839828]

Comment 2 Tomas Hoger 2020-05-27 12:20:46 UTC
In reply to comment #0:
> libmariadb/mariadb_lib.c in MariaDB Connector/C before 3.1.8 does not
> properly validate the content of an OK packet received from a client.

This description is incorrect, as "An OK packet is sent from the server to the client to signal successful completion of a command.":

https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html

Comment 3 Tomas Hoger 2020-05-27 12:25:49 UTC
MariaDB Connector/C is included with MariaDB Server 10.2 and later.  The fixed Connector/C version was added to Server source code via this commit:

https://github.com/MariaDB/server/commit/1d1fb13e59

in versions 10.2.32, 10.3.23, 10.4.13, and 10.5.3.

Comment 4 Tomas Hoger 2020-05-28 22:10:51 UTC
The fix linked in comment 0 corrects multiple out-of-bounds read issues.  They were possible because of insufficient checks of lengths of various fields extracted from OK packets received form a MySQL/MariaDB server - when field length was extracted from the packet, MariaDB Connector/C did not ensure that the length does no exceed the remaining size of the package received.  These issues could trigger crash.

However, there was also an out-of-bounds write issue, where a value read from the packet was copied to a fixed size buffer cs_name[] without checking the size of the data:

https://github.com/mariadb-corporation/mariadb-connector-c/blob/v3.1.7/libmariadb/mariadb_lib.c#L2132-L2135

Comment 6 Tomas Hoger 2020-06-04 07:29:39 UTC
Created mariadb tracking bugs for this issue:

Affects: fedora-all [bug 1843795]


Created mariadb:10.3/mariadb tracking bugs for this issue:

Affects: fedora-all [bug 1843796]


Created mariadb:10.4/mariadb tracking bugs for this issue:

Affects: fedora-all [bug 1843797]

Comment 7 Tomas Hoger 2020-06-04 08:08:29 UTC
There is another case when out-of-bounds write can happen.  The following code sets mysql->info to point directly into the input packet data without creating a copy:

https://github.com/mariadb-corporation/mariadb-connector-c/blob/v3.1.7/libmariadb/mariadb_lib.c#L2045-L2046

and subsequently ensures that the data is correctly zero terminated:

https://github.com/mariadb-corporation/mariadb-connector-c/blob/v3.1.7/libmariadb/mariadb_lib.c#L2065-L2067

However, missing field length checks as noted in comment 4 can cause the 0 to be written outside of the allocated buffer.

Comment 8 Tomas Hoger 2020-06-04 20:22:41 UTC
Actually, my info in comment 7 seems wrong - this check should have prevented write beyond the end of the packet:

https://github.com/mariadb-corporation/mariadb-connector-c/blob/v3.1.7/libmariadb/mariadb_lib.c#L2057

Comment 12 errata-xmlrpc 2020-10-05 15:15:53 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 6
  Red Hat Software Collections for Red Hat Enterprise Linux 7
  Red Hat Software Collections for Red Hat Enterprise Linux 7.6 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 7.7 EUS

Via RHSA-2020:4174 https://access.redhat.com/errata/RHSA-2020:4174

Comment 13 Product Security DevOps Team 2020-10-05 20:21:12 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2020-13249

Comment 14 errata-xmlrpc 2020-11-30 13:44:57 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 7
  Red Hat Software Collections for Red Hat Enterprise Linux 7.6 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 7.7 EUS

Via RHSA-2020:5246 https://access.redhat.com/errata/RHSA-2020:5246

Comment 15 errata-xmlrpc 2020-12-15 17:10:17 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2020:5500 https://access.redhat.com/errata/RHSA-2020:5500

Comment 16 errata-xmlrpc 2020-12-15 17:11:15 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2020:5503 https://access.redhat.com/errata/RHSA-2020:5503

Comment 17 errata-xmlrpc 2020-12-22 09:02:21 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.2 Extended Update Support

Via RHSA-2020:5654 https://access.redhat.com/errata/RHSA-2020:5654

Comment 18 errata-xmlrpc 2020-12-22 09:07:26 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.2 Extended Update Support

Via RHSA-2020:5655 https://access.redhat.com/errata/RHSA-2020:5655

Comment 19 errata-xmlrpc 2020-12-22 09:15:49 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.1 Extended Update Support

Via RHSA-2020:5660 https://access.redhat.com/errata/RHSA-2020:5660

Comment 20 errata-xmlrpc 2020-12-22 09:24:45 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.0 Update Services for SAP Solutions

Via RHSA-2020:5663 https://access.redhat.com/errata/RHSA-2020:5663

Comment 21 errata-xmlrpc 2020-12-22 09:25:56 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.1 Extended Update Support

Via RHSA-2020:5665 https://access.redhat.com/errata/RHSA-2020:5665

Comment 22 errata-xmlrpc 2020-12-22 09:27:57 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.0 Update Services for SAP Solutions

Via RHSA-2020:5662 https://access.redhat.com/errata/RHSA-2020:5662


Note You need to log in before you can comment on or make changes to this bug.