mrkkrp / zip

Efficient library for manipulating zip archives
Other
81 stars 27 forks source link

Behaviour of the library with malicious files #17

Closed hce closed 8 years ago

hce commented 8 years ago

Not a bug, just a question: I'm using the library to process files that users upload via a web interface. Now I'm wondering this:

How does the library behave if someone specifically crafts a malicous file:

mrkkrp commented 8 years ago

Good question, I need to think about it. It's certainly not possible to make meta-data larger than it can be (size of comment is stored as 2 byte value so it cannot be longer than 0xffff, other things are handled similarily). I don't see how you can get it into endless loop too. Basically if file is not large, it will be traversed quickly, or its end will be discovered anyway. This library does not ever read archive contents in memory. It stores operations and then you can think about it as one loop that reads bytes from source, modifies them if necessary and writes to destination file right away.

I would advise checking size of files. If you limit size of files, there is no way to attack you via the library (at least right now I don't see how it can be done).

hce commented 8 years ago

Okay, thank you very much for the response! Filesize is indeed limited to ~1GB. I will also have a look into the library and if I find anything, I'll report it here. IMHO we can close this ticket in the meantine.