GitHub advisory · RubyGems
permessage-deflate-ruby: Memory exhaustion triggered by message decompression
RubyGems
What it fixes
An unauthenticated remote client can cause a server to allocate memory with a much larger size than the message sent over the wire, potentially bypassing configured message size limits. This may cause the server to run out of memory and crash.
permessage-deflate is used to add support for compression extensions to [websocket-driver][wd-ruby], [faye-websocket][fw-ruby] and other libraries based on these packages. A client with this extension activated can compress a very large message consisting of one byte repeated many times to around 1/1,000 of its original size before sending it to the server. Upon receiving such a message, the server will decompress it, and thereby allocate a buffer 1,000 times larger than the received WebSocket frame. The client may abuse this to cause the server to allocate such much that it runs out of memory and crashes. This is possible even if the client is using the most conservative possible parameters for the extension in terms of minimising zlib memory usage.
If a :max_length option has been set by [websocket-driver][wd-ruby] or [faye-websocket][fw-ruby], this is not passed on to the permessage-deflate extension. The extension fully decompresses the received message, and only after this has happened does [websocket-driver][wd-ruby] decide whether the message is too large.
To mitigate this, permessage-deflate has been updated to accept the :max_length option and enforce this as it consumes the zlib inflate output stream. For this to take effect, websocket-extensions and [websocket-driver][wd-ruby] must also be upgraded in order to forward the :max_length option to the extension.
Alternatively, the vulnerability can be mitigated by removing the permessage-deflate extension from the server configuration.
Manual fix · RubyGems
bundle update permessage_deflatebundle update websocket-driverbundle update websocket-extensionsSources