CVE-2021-25291: Out of Bounds Read in Pillow

pillow Updated 02 Oct 2025

Summary

29/03/2021
Yes i
High
7.5

CVE-2021-25291: Out of bounds read in Pillow. Affects pillow versions < 8.2.0. Fixed in 8.2.0. How to fix ↓

Also tracked for

The same CVE-2021-25291 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

Pillow is a popular Python imaging library that provides support for opening, manipulating, and saving many different image file formats. It is widely used in various applications for image processing and manipulation. However, an out-of-bounds read vulnerability has been discovered in Pillow versions before 8.1.1. This vulnerability, identified as CVE-2021-25291, specifically affects the TiffDecode.c module in Pillow. The issue arises from an invalid tile boundary in the TiffreadRGBATile function, leading to an out-of-bounds read operation.

Vulnerability Detail

The out-of-bounds read vulnerability in Pillow can be exploited by an attacker to read data beyond the boundaries of a valid tile. This could potentially result in the disclosure of sensitive information or the execution of arbitrary code. The vulnerability has been assigned a CVSS score of 7.5, indicating a high severity level. The CWE-125 category is associated with this vulnerability, which refers to out-of-bounds read issues. The vulnerability was discovered on March 29, 2021, and it was reviewed by GitHub on March 22, 2021.

How To Fix

Latest published version: 13.0.0 as of 22 Oct 2026

pip install --upgrade "pillow==13.0.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

8.2.0

This is the first release that contains the fix.

pip install --upgrade "pillow==8.2.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a workaround, if upgrading to the latest version of Pillow is not immediately feasible, developers can consider implementing input validation and sanitization techniques to prevent malicious inputs from triggering the out-of-bounds read vulnerability. Additionally, restricting access to the affected functionality or implementing proper access controls can help mitigate the risk associated with this vulnerability.

Conclusion

In conclusion, the out-of-bounds read vulnerability in Pillow versions before 8.1.1 poses a significant risk to applications utilizing this library for image processing. It is crucial to upgrade to the latest version of Pillow (8.2.0 or later) to mitigate this vulnerability. Developers should also consider implementing input validation and access controls as temporary workarounds. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for pillow →

Share this vulnerability

FAQ

Pillow is a Python imaging library that provides support for opening, manipulating, and saving various image file formats.

The vulnerability allows an attacker to read data beyond the boundaries of a valid tile, potentially leading to information disclosure or arbitrary code execution.

The CVSS score of this vulnerability is 7.5, indicating a high severity level.

To fix this vulnerability, it is recommended to upgrade Pillow to version 8.2.0 or later.

As a workaround, developers can implement input validation and sanitization techniques or restrict access to the affected functionality.

Related vulnerabilities

Recent vulnerabilities recorded for pillow.

How To Fix

Latest published version: 13.0.0 as of 22 Oct 2026

pip install --upgrade "pillow==13.0.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

8.2.0

This is the first release that contains the fix.

pip install --upgrade "pillow==8.2.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback