Limiting which formats are loaded with PIL images

To reduce the number of possible attack vectors on a website, which would be the best way to limit formats, the Python Imaging Library can read a set of well-known good codecs (GIF, JPEG, PNG).

Thus, users could not send more exotic formats and use possible codec errors for buffer overflows, etc.

Preferably at runtime.

+4
source share
1 answer

You can use python-magic to check the accepted mimety types before passing the file / buffer to PIL.

+3
source

Source: https://habr.com/ru/post/1491054/


All Articles