A buffer overflow vulnerability in FliDecode.c was reported, affecting all versions of python-pillow at least from 1.1.7 release. Vulnerable code: case 16: /* COPY chunk */ for (y = 0; y < state->ysize; y++) { UINT8* buf = (UINT8*) im->image[y]; memcpy(buf+x, data, state->xsize); data += state->xsize; } break; x is used in several internal temporary variable roles, but can take a value up to the width of the image from different chunk sizes. im->image[y] is a set of row pointers to segments of memory that are the size of the row. At the max y, this will write the contents of the line off the end of the memory buffer. This writes into python object storage in a region where there are function pointers. Reproducer and proposed fix can be found in original bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1300660
Acknowledgements: Red Hat would like to thank the Pillow project for reporting this issue. Upstream acknowledges Alyssa Besseling as the original reporter.