Jul 21, 2026·3 min read·43 visits
Integer overflow in Pillow image expansion leads to heap out-of-bounds write. Initial patch introduces a division-by-zero crash.
A heap out-of-bounds write vulnerability exists in Pillow prior to version 12.3.0 due to an integer overflow during image expansion calculations. The subsequent patch introduced a division-by-zero regression causing denial of service.
Pillow is a Python Imaging Library that provides image processing capabilities. The vulnerability exists within the native C extension libImaging, specifically in the image expansion and filtering code paths.\n\nAn attacker can trigger this vulnerability by providing an extremely large filter size parameter to ranking filters. This input flows from the Python layer into native C functions without sufficient prior validation.\n\nThe resulting calculation causes a signed integer overflow. This leads to severe memory corruption or application crashes.
The root cause lies in src/libImaging/Filter.c within the ImagingExpand function. When an application initializes a filter, the Python layer calculates the margin parameter using floor division.\n\nFor extremely large filter sizes, this division yields a margin value close to INT_MAX. When passed to the C library, the output dimensions are computed via addition and multiplication.\n\nSpecifically, the formula imIn->xsize + 2 * margin overflows the 32-bit signed integer limits. This mathematical wraparound results in a very small dimension value.\n\nConsequently, the library allocates an undersized destination buffer. However, the subsequent copying loop still uses the original large margin, resulting in an out-of-bounds write.
The vulnerable calculation path computes the destination buffer size based on the overflowed dimensions.\n\nc\n/* Vulnerable dimension calculation */\nint xsize = imIn->xsize + 2 * margin;\nint ysize = imIn->ysize + 2 * margin;\n\n/* Allocation of undersized buffer */\nimOut = ImagingNewDirty(imIn->mode, xsize, ysize);\n\n\nThe loop then iterates using the un-overflowed margin to copy pixels.\n\nc\n/* Out-of-bounds copy loop */\nfor (y = 0; y < margin; y++) {\n for (x = 0; x < margin; x++) {\n imOut->image[y][x] = imIn->image[...];\n }\n}\n\n\nThe patch attempted to check bounds but introduced a division-by-zero error.\n\nc\n/* Patched boundary check introducing regression */\nif (margin > INT_MAX / (margin * (int)sizeof(FLOAT32))) {\n return (Imaging)ImagingError_ValueError(\"filter size too large\");\n}\n
An attacker can exploit this flaw by submitting images or filter size parameters designed to trigger the overflow. This allows sequential overwriting of heap data with pixel values derived from the input image.\n\nControl over pixel values enables targeted heap corruption. This can lead to remote code execution in contexts where untrusted input dictates filter dimensions.\n\nAdditionally, the patch regression allows a straightforward denial of service attack. Passing a filter size of 1 translates to a margin of 0, triggering the division-by-zero trap.
Users should upgrade to Pillow version 12.3.0 or later to resolve the heap out-of-bounds write. This release contains validation checks that prevent large values from reaching the C execution layer.\n\nFor systems where upgrading is not immediately possible, strict input validation should be enforced. Applications should restrict filter size parameters to reasonable boundaries.\n\nFurthermore, the division-by-zero issue can be mitigated by ensuring that the margin parameter is non-zero before invoking the expansion functions.
| Product | Affected Versions | Fixed Version |
|---|---|---|
Pillow Pillow | < 12.3.0 | 12.3.0 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-190, CWE-787 |
| Attack Vector | Network |
| CVSS v3.1 Score | 8.2 |
| Impact | Heap Out-of-Bounds Write / Denial of Service |
| Exploit Status | PoC Available |
A path traversal vulnerability (CWE-22) in Contao CMS allows unauthenticated remote attackers to bypass directory boundary restrictions in ImagesController and access files within the project directory.
Contao Open Source CMS versions 4.0.0 through 5.3.49 and 5.4.0-RC1 through 5.7.11 contain a Cross-Site Request Forgery (CSRF) vulnerability in backend parameter handling. The `RequestTokenListener` component validates anti-CSRF tokens solely for HTTP POST requests, while GET-based declarative guards run only when an `act` parameter is present in the query string. Consequently, custom backend actions dispatched via alternative parameters such as `key=` can execute without CSRF token verification when triggered by an authenticated user.
Contao CMS versions 4.1.0 through 5.3.49 and 5.4.0-RC1 through 5.7.11 fail to validate form submission tokens and enforce rate limiting when processing activation email resend requests via HTTP POST, enabling resource exhaustion and account state enumeration.
An information disclosure vulnerability in Contao CMS allows unauthenticated site visitors to view protected page titles, URLs, and text excerpts through search queries when protected page indexing is disabled after previously being enabled.
In Vikunja prior to version 2.6.0, relation creation via the CalDAV endpoint fails to invoke the TaskRelation.CanCreate authorization check. This missing access control allows an authenticated user to establish unauthorized relationships and perform write operations against any task, provided its unique identifier (UID) is known.
A cross-project information disclosure vulnerability in Vikunja allows authenticated users with read access to one project to view private task details from unauthorized projects via subtask expansion parameters.