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 , faye-websocket 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 maxLength option has been set by websocket-driver or faye-websocket , 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 decide whether the message is too large.
To mitigate this, permessage-deflate has been updated to accept the maxLength option and enforce this as it consumes the zlib inflate output stream. For this to take effect, websocket-extensions and websocket-driver must also be upgraded in order to forward the maxLength option to the extension.
Alternatively, the vulnerability can be mitigated by removing the permessage-deflate extension from the server configuration.
A server is affected by this if it is running any WebSocket processing stack that includes this extension. For example, the following server uses the extension via websocket-driver with maxLength set to 1 MiB.
A client can trigger a larger than expected allocation by sending a message that is larger than the server's configured maxLength , for example:
Running this client will cause the server to print that it received 4,089 bytes, but did not emit a message event, and the client exits with this close event:
Although the server rejects the message as too large, it will in fact have inflated it to its full size of 4 MiB before making this decision.
After installing the patched release(s), the client will instead print:
The changed error message indicates that the extension is rejecting the message after maxLength bytes have been output by zlib , and it stops consuming the output stream before the message is fully inflated.
Users running permessage-deflate on a server in a memory-constrained environment may be at risk of denial of service that can be triggered by an unauthenticated remote client. Users should upgrade packages as indicated by this advisory, or remove permessage-deflate from their configuration.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
