The vulnerability is an out-of-bounds write caused by a lack of validation on tile offsets when processing image files in the Pillow library. The core of the vulnerability lies in the C-level function _setimage within src/decode.c, which is responsible for handling image tiles during the decoding process. The patch 54ba4db542ad3c7b918812a4e2d69c27735a3199 clearly shows the addition of checks to ensure the tile offsets (xoff and yoff) are not negative. Without these checks, a malicious image file could specify negative offsets, causing the function to write data before the start of the allocated memory buffer.
The Python-level entry point for this vulnerability is the load() method of the PsdImageFile class. When a user opens a crafted PSD image and the load() method is called (either explicitly or implicitly), it triggers the vulnerable C decoding function, resulting in the out-of-bounds write. The analysis of the patch also revealed a similar vulnerability in the encoding path in src/encode.c, which was fixed in the same commit. Therefore, both the decoding and encoding _setimage functions are identified as vulnerable, with the PsdImageFile.load method being the primary way to trigger the vulnerability during runtime.