by pygy_ · 13y ago · 0 comments
A DEFLATE stream [0] is made of blocks whose first bit determines whether it is the last one.
One could add a number of random bytes after the last block such that the payload always has the same length, or is a multiple of a reasonably large number of bytes.
This assumes that the decoder will ignore it whatever follows the last block.
Another, cleaner option: Use a Trailer HTTP header, using Chunked transfer encoding[1].
The technique should also work with gzip.
--
[0] http://en.wikipedia.org/wiki/DEFLATE#Stream_format, http://www.ietf.org/rfc/rfc1951.txt
You could also add a random amount of random padding. It would slow down the attack linearly if the random amount is taken from a uniform distribution.
I wonder if it would be possible to make it slower by taking another distribution.