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: 1841915 1841916 1841918 1894126 1839828 1841917 1843795 1843796 1843797 1880332
Blocks: 1839829
TreeView+ depends on / blocked
 
Reported: 2020-05-25 16:53 UTC by Pedro Sampaio
Modified: 2020-11-03 15:34 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


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2020:4174 None None None 2020-10-05 15:15:56 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


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