VYPR
Critical severityNVD Advisory· Published Jan 3, 2020· Updated Aug 4, 2024

CVE-2020-5312

CVE-2020-5312

Description

libImaging/PcxDecode.c in Pillow before 6.2.2 has a PCX P mode buffer overflow.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Buffer overflow in Pillow's PCX P mode decoding allows remote code execution via crafted images.

Vulnerability

CVE-2020-5312 is a buffer overflow vulnerability in the libImaging/PcxDecode.c file of Pillow, a Python imaging library. The flaw exists in versions before 6.2.2 when decoding PCX images in "P" (palette) mode. Specifically, the code does not properly validate the size of the palette data, leading to a heap buffer overflow.

Exploitation

An attacker can exploit this vulnerability by providing a specially crafted PCX image to an application that uses Pillow to process images. No authentication is required, and the attack can be delivered via any vector that allows a user to open or process a malicious PCX file, such as email attachments, web uploads, or downloaded content.

Impact

Successful exploitation could allow an attacker to execute arbitrary code on the affected system. The vulnerability has been assigned a CVSS base score of 9.8 (Critical) as per the Red Hat advisory, indicating remote code execution with low attack complexity and no privileges required [2][4].

Mitigation

The vulnerability is fixed in Pillow version 6.2.2 and later. Red Hat has released updates for RHEL 7 and 8 via RHSA-2020:0578 and RHSA-2020:0580 [1][2]. Ubuntu has also addressed the issue in USN-4272-1 [4]. Users are strongly advised to update their Pillow installations to the latest patched version.

AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
pillowPyPI
< 6.2.26.2.2

Affected products

300

Patches

2
a45c8583ff90

Release notes for 6.2.2

https://github.com/python-pillow/pillowAndrew MurrayJan 2, 2020via osv
1 file changed · +1 0
  • docs/releasenotes/index.rst+1 0 modified
    @@ -6,6 +6,7 @@ Release Notes
     .. toctree::
       :maxdepth: 2
     
    +  6.2.2
       6.2.1
       6.2.0
       6.1.0
    
93b22b846e02

Catch PCX P mode buffer overrun

https://github.com/python-pillow/pillowAndrew MurrayDec 21, 2019via osv
3 files changed · +9 1
  • src/libImaging/PcxDecode.c+3 0 modified
    @@ -25,6 +25,9 @@ ImagingPcxDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t byt
         if (strcmp(im->mode, "1") == 0 && state->xsize > state->bytes * 8) {
             state->errcode = IMAGING_CODEC_OVERRUN;
             return -1;
    +    } else if (strcmp(im->mode, "P") == 0 && state->xsize > state->bytes) {
    +        state->errcode = IMAGING_CODEC_OVERRUN;
    +        return -1;
         }
     
         ptr = buf;
    
  • Tests/images/pcx_overrun2.bin+0 0 added
  • Tests/test_image.py+6 1 modified
    @@ -590,7 +590,12 @@ def act(fp):
                 self.assertFalse(fp.closed)
     
         def test_overrun(self):
    -        for file in ["fli_overrun.bin", "sgi_overrun.bin", "pcx_overrun.bin"]:
    +        for file in [
    +            "fli_overrun.bin",
    +            "sgi_overrun.bin",
    +            "pcx_overrun.bin",
    +            "pcx_overrun2.bin",
    +        ]:
                 im = Image.open(os.path.join("Tests/images", file))
                 try:
                     im.load()
    

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

19

News mentions

0

No linked articles in our index yet.