Bug 1929858 (CVE-2021-27219)

Summary: CVE-2021-27219 glib: integer overflow in g_bytes_new function on 64-bit platforms due to an implicit cast from 64 bits to 32 bits
Product: [Other] Security Response Reporter: Guilherme de Almeida Suckevicz <gsuckevi>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: caillon+fedoraproject, dblechte, dfediuck, eedri, erack, erik-fedora, fedora, fidencio, gferrazs, gnome-sig, jhorak, kaycoth, klember, kyoshida, manisandro, marcandre.lureau, mcatanza, mclasen, mdean, mgoldboi, michal.skrivanek, nobody, pahan, paul, rdieter, rhel8-maint, rh-spice-bugs, rhughes, rjones, rschiron, rstrode, sandmann, sbonazzo, security-response-team, sherold, stransky, tcrider, tiagomatos, tpopela, walters, xiwu, yturgema
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: glib 2.67.3, glib 2.66.6 Doc Type: If docs needed, set a value
Doc Text:
An integer wraparound was discovered in glib due to passing a 64 bit sized value to function g_memdup() which accepts a 32 bits number as argument. An attacker may abuse this flaw when an application linked against the glib library uses g_bytes_new() function or possibly other functions that use g_memdup() underneath and accept a 64 bits argument as size. The highest threat from this vulnerability is to data confidentiality and integrity as well as system availability.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-31 11:32:02 UTC Type: ---
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: 1941686, 1929859, 1929860, 1929861, 1929862, 1939107, 1939108, 1939109, 1939110, 1939111, 1941679, 1941680, 1941681, 1941682, 1941684, 1941685, 1941687, 1941688, 1941689, 1960591, 1960592, 1960593, 1960594, 1960595, 1960596, 1960597, 1960598, 1960599, 1960600, 1960601, 1967845, 1967846    
Bug Blocks: 1929863    

Description Guilherme de Almeida Suckevicz 2021-02-17 19:18:46 UTC
An issue was discovered in GNOME GLib before 2.66.6 and 2.67.x before 2.67.3. The function g_bytes_new has an integer overflow on 64-bit platforms due to an implicit cast from 64 bits to 32 bits. The overflow could potentially lead to memory corruption.

Reference:
https://gitlab.gnome.org/GNOME/glib/-/issues/2319

Comment 1 Guilherme de Almeida Suckevicz 2021-02-17 19:19:17 UTC
Created glib tracking bugs for this issue:

Affects: epel-7 [bug 1929861]
Affects: fedora-all [bug 1929859]


Created glib2 tracking bugs for this issue:

Affects: fedora-all [bug 1929860]


Created mingw-glib2 tracking bugs for this issue:

Affects: fedora-all [bug 1929862]

Comment 7 Riccardo Schirone 2021-05-13 14:21:43 UTC
GBytes is used to have an immutable representation of an array of bytes, so applications may read from it rather than writing user-controlled data into the allocated buffer. That effectively makes this more similar to an out-of-bounds read than to a flaw allowing (at least directly) memory corruption. For this reason, this flaw was rated as having a Moderate impact.

Comment 11 Riccardo Schirone 2021-05-14 08:56:59 UTC
In reply to comment #7:
> GBytes is used to have an immutable representation of an array of bytes, so
> applications may read from it rather than writing user-controlled data into
> the allocated buffer. That effectively makes this more similar to an
> out-of-bounds read than to a flaw allowing (at least directly) memory
> corruption. For this reason, this flaw was rated as having a Moderate impact.

After re-analyzing this issue, we re-evaluated this flaw as having an Important impact. This is due to the fact that the buffer allocated within GBytes could be taken through functions such as g_bytes_unref_to_data, which would report the wrong (big) size. Such data pointer and size could be used to write data into the raw buffer, wrongly assuming that `size` bytes are available in the buffer, though only a small amount of bytes have been allocated due to the integer truncation within GBytes. Such writes would be out-of-bounds and they could allow an attacker to execute code with the privileges of the application.

Comment 19 errata-xmlrpc 2021-05-31 10:14:45 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2021:2147 https://access.redhat.com/errata/RHSA-2021:2147

Comment 20 Product Security DevOps Team 2021-05-31 11:32:02 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-2021-27219

Comment 21 errata-xmlrpc 2021-06-01 10:46:02 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.1 Extended Update Support

Via RHSA-2021:2172 https://access.redhat.com/errata/RHSA-2021:2172

Comment 22 errata-xmlrpc 2021-06-01 10:52:09 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7.3 Advanced Update Support

Via RHSA-2021:2173 https://access.redhat.com/errata/RHSA-2021:2173

Comment 23 errata-xmlrpc 2021-06-01 10:55:09 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.2 Extended Update Support

Via RHSA-2021:2171 https://access.redhat.com/errata/RHSA-2021:2171

Comment 24 errata-xmlrpc 2021-06-01 11:21:41 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7.4 Advanced Update Support
  Red Hat Enterprise Linux 7.4 Update Services for SAP Solutions
  Red Hat Enterprise Linux 7.4 Telco Extended Update Support

Via RHSA-2021:2174 https://access.redhat.com/errata/RHSA-2021:2174

Comment 25 errata-xmlrpc 2021-06-01 11:42:43 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2021:2170 https://access.redhat.com/errata/RHSA-2021:2170

Comment 26 errata-xmlrpc 2021-06-01 12:02:11 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7.7 Extended Update Support

Via RHSA-2021:2175 https://access.redhat.com/errata/RHSA-2021:2175

Comment 27 errata-xmlrpc 2021-06-02 14:58:29 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7.2 Advanced Update Support

Via RHSA-2021:2203 https://access.redhat.com/errata/RHSA-2021:2203

Comment 28 errata-xmlrpc 2021-06-02 16:33:47 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7.6 Extended Update Support

Via RHSA-2021:2204 https://access.redhat.com/errata/RHSA-2021:2204

Comment 29 Vance 2021-06-03 16:01:58 UTC
This vulnerability is also present in the latest ubi8 image. When can we expect a new image?

Thanks!

Comment 35 errata-xmlrpc 2021-06-17 10:05:40 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 6 Extended Lifecycle Support

Via RHSA-2021:2467 https://access.redhat.com/errata/RHSA-2021:2467

Comment 36 errata-xmlrpc 2021-06-22 13:20:31 UTC
This issue has been addressed in the following products:

  Red Hat Virtualization 4 for Red Hat Enterprise Linux 7

Via RHSA-2021:2519 https://access.redhat.com/errata/RHSA-2021:2519

Comment 37 errata-xmlrpc 2021-06-22 14:55:00 UTC
This issue has been addressed in the following products:

  Red Hat Virtualization 4 for Red Hat Enterprise Linux 8

Via RHSA-2021:2522 https://access.redhat.com/errata/RHSA-2021:2522

Comment 38 errata-xmlrpc 2021-06-22 15:26:29 UTC
This issue has been addressed in the following products:

  Red Hat Virtualization 4 for Red Hat Enterprise Linux 8

Via RHSA-2021:2522 https://access.redhat.com/errata/RHSA-2021:2522

Comment 41 errata-xmlrpc 2021-11-09 19:06:53 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2021:4526 https://access.redhat.com/errata/RHSA-2021:4526