-
Notifications
You must be signed in to change notification settings - Fork 79
Description
@thejoshwolfe thanks for a brilliant module.
Firstly, and this is more something that's lacking in the zlib api which we should change, but I noticed that yauzl doesn't let createInflateRaw
know that it only expects the uncompressed buffer to be at most uncompressed size
bytes, and that zlib should stop decoding and throw an error once it hits the uncompressed size
limit.
Secondly, yauzl doesn't check the inflated buffer length returned by zlib to ensure that it matches the uncompressed size
exactly.
Simply checking uncompressed size
alone before inflating is not enough, since uncompressed size
is untrusted user data and could be fraudulent, i.e. much less than that indicated by the actual zlib stream.
Both of these protections are necessary for defending against zip bombs, otherwise the user might check that uncompressed size
is within limits, yet zlib might carry on decoding hundreds of megabytes past this limit. And if yauzl sees that the sizes do not match up after the fact, then it should probably warn the user, otherwise multiple instances of this mismatch might add up to something more severe across multiple files.