CVE-2021-25289: Pillow Out Of Bounds Write Vulnerability
CRITICALCVE-2021-25289 is a CRITICAL (CVSS 9.8) out of bounds write vulnerability (CWE-787: Out-of-bounds Write) affecting Pillow libraries in the PyPI ecosystem. The issue involves out of bounds write in pillow. Remediation is available by upgrading affected packages to version 8.1.1.
CVE-2021-25289 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2021-25289
To remediate this vulnerability, upgrade all affected Pillow dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install pillow>=8.1.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show pillow
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2021-25289, inspect your installed packages using pip:
pip show pillow
Analyze the terminal output to locate any version of Pillow in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.1.1), your application is affected.
Note: The pip show pillow command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-787: Out-of-bounds Write, where the product writes data past the end, or before the beginning, of the intended buffer. In Pillow, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-25289 Affected Pillow Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pillow
|
PyPI |
< 8.1.1
|
8.1.1
|
References
Frequently Asked Questions
What is CVE-2021-25289?
Which Pillow versions are affected?
What version fixes CVE-2021-25289?
Is pillow affected?
What is the CVSS score of CVE-2021-25289?
What CWE is associated with CVE-2021-25289?
How can I check PyPI dependencies for CVE-2021-25289?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-57h3-9rgr-c24m",
"modified" : "2024-10-08T13:11:32Z",
"published" : "2021-03-29T16:35:16Z",
"aliases" : [ "CVE-2021-25289" ],
"summary" : "Out of bounds write in Pillow",
"details" : "An issue was discovered in Pillow before 8.1.1. TiffDecode has a heap-based buffer overflow when decoding crafted YCbCr files because of certain interpretation conflicts with LibTIFF in RGBA mode. NOTE: this issue exists because of an incomplete fix for CVE-2020-35654.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "pillow"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "8.1.1"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-25289"
}, {
"type" : "WEB",
"url" : "https://github.com/python-pillow/Pillow/commit/3fee28eb9479bf7d59e0fa08068f9cc4a6e2f04c"
}, {
"type" : "WEB",
"url" : "https://github.com/python-pillow/Pillow/commit/cbfdde7b1f2295059a20a539ee9960f0bec7b299"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-57h3-9rgr-c24m"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pillow/PYSEC-2021-35.yaml"
}, {
"type" : "WEB",
"url" : "https://github.com/python-pillow/Pillow"
}, {
"type" : "WEB",
"url" : "https://pillow.readthedocs.io/en/stable/releasenotes/8.1.1.html"
}, {
"type" : "WEB",
"url" : "https://security.gentoo.org/glsa/202107-33"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-787" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2021-03-22T22:07:48Z",
"nvd_published_at" : "2021-03-19T04:15:00Z"
}
}