hMatoba / Piexif

Exif manipulation with pure python script.
MIT License
367 stars 81 forks source link

`load`'s permissiveness allows unexpected attacker-controlled reads. #85

Open christophebiocca opened 5 years ago

christophebiocca commented 5 years ago

load takes either bytes of a picture or a filename, and provides the caller with no way to specify which way to interpret the data.

So a caller accepting images over the network and passing the received bytes into load directly will be in for a nasty surprise when an attacker makes an "image" composed of any of the following byte sequences:

The only safe thing for someone writing a web-service then becomes:

  1. Get the bytes.
  2. Get a temporary file.
  3. Write the bytes out to the temporary file.
  4. Pass the temporary file's path to load.