Memory leak when using zlib.inflate to inflate invalid data v10.9.0 #22705
Labels
confirmed-bug
Issues with confirmed bugs.
memory
Issues and PRs related to the memory management or memory footprint.
zlib
Issues and PRs related to the zlib subsystem.
Version: 10.9.0
Platform: Linux Ubuntu 3.13.0-36-generic
Subsystem: zlib
I've recently updated a large project from Node 8.11.3 to 10.9.0 but the service crashes after a few minutes because of memory exhaustion (4GB RAM). I've narrowed down the issue to the use of the asynchronous zlib.inflate method if the input isn't a valid input.
I've been able to create a small script which shows the issue
When using Node 8.11.3 I get the following output from that script, you can see memory usage levels out around 280MiB.
Switching to Node 10.9.0 I get the following output
After 200k iterations the 8.11.3 version uses 280MiB but the 10.9.0 version is using 1400MiB of memory. After about 300k iterations using 10.9.0 the process crashes because it runs out of RAM.
Running the script with the "valid" parameter to send zlib a valid stream shows an increase in memory but it's small and eventually levels out and doesn't run out of memory.
I've corrected our service so that we check for invalid streams before trying to inflate them but I thought that there is potential for a denial of service against any service which uses zlib.inflate to decompress user input.
The text was updated successfully, but these errors were encountered: