Bug 1789535 (CVE-2020-5311)

Summary: CVE-2020-5311 python-pillow: out-of-bounds write in expandrow in libImaging/SgiRleDecode.c
Product: [Other] Security Response Reporter: Pedro Sampaio <psampaio>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: bdettelb, cstratak, dbecker, jjoyce, jschluet, jschorr, kbasil, lhh, lpeer, manisandro, mburns, miminar, orion, python-maint, sclewis, slinaber, tomckay, torsava, tsmetana
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: python-pillow 6.2.2 Doc Type: If docs needed, set a value
Doc Text:
An out-of-bounds write flaw was discovered in python-pillow in the way SGI RLE images are decoded. An application that uses python-pillow to decode untrusted images may be vulnerable to this flaw, which can allow an attacker to crash the application or potentially execute code on the system.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-02-21 03:49:44 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: 1789541, 1789542, 1799358, 1799360, 1799361    
Bug Blocks: 1789544    

Description Pedro Sampaio 2020-01-09 18:52:24 UTC
libImaging/SgiRleDecode.c in Pillow before 6.2.2 has an SGI buffer overflow.

Upstream patch:

https://github.com/python-pillow/Pillow/commit/a79b65c47c7dc6fe623aadf09aa6192fc54548f3

References:

https://pillow.readthedocs.io/en/stable/releasenotes/6.2.2.html

Comment 1 Pedro Sampaio 2020-01-09 19:04:19 UTC
Created python-pillow tracking bugs for this issue:

Affects: fedora-all [bug 1789541]


Created python3-pillow tracking bugs for this issue:

Affects: epel-7 [bug 1789542]

Comment 2 Jason Shepherd 2020-01-10 02:23:56 UTC
While Red Hat Quay includes the python-pillow it's not used, therefore this issue is rated moderate for Red Hat Quay.

Comment 5 Riccardo Schirone 2020-02-06 14:45:56 UTC
Statement:

This issue did not affect the versions of python-pillow and python-imaging as shipped with Red Hat Enterprise Linux 6, and 7 as they did not include the SGI RLE image decoder, where the flaw lies.

Comment 6 Riccardo Schirone 2020-02-06 14:54:48 UTC
Function expandrow() is called by ImagingSgiRleDecode() in SgiRleDecode.c to load and decode an input image. While reading compressed rows of the input image, expandrow() does not consider the image size, thus it is possible to overwrite past the end of the output buffer. This flaw could be used by an attacker to overwrite heap metadata and potentially execute code.

Comment 8 errata-xmlrpc 2020-02-20 22:16:49 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.0 Update Services for SAP Solutions

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

Comment 9 Product Security DevOps Team 2020-02-21 03:49:44 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-5311

Comment 10 errata-xmlrpc 2020-02-24 12:56:43 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

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

Comment 11 errata-xmlrpc 2021-02-04 16:14:19 UTC
This issue has been addressed in the following products:

  Red Hat Quay 3

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