Reputation: 83676
To decrease the amount of possible attack vectors on a website, what would be the best way to limit formats Python Imaging Library can read to the set of known good codecs (GIF, JPEG, PNG).
This way the users could not submit more exotic formats and exploit possible codec bugs to do buffer overflow, etc. style attack.
Preferably in run-time.
Upvotes: 4
Views: 211
Reputation: 181
You can use python-magic to check for accepted mimetypes before passing the file/buffer to PIL.
Upvotes: 3