Skip to content

Commit 0e36912

Browse files
committed
Fixed large DoS vector in the middleware implementation
1 parent 0c71119 commit 0e36912

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/node-http-proxy.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,19 @@ exports.stack = function stack (middlewares, proxy) {
222222
handle = function (req, res) {
223223
var next = function (err) {
224224
if (err) {
225-
throw err;
226-
//
227-
// TODO: figure out where to send errors.
228-
// return error(req, res, err);
229-
//
225+
if (res._headerSent) {
226+
res.destroy();
227+
}
228+
else {
229+
res.statusCode = 500;
230+
res.setHeader('Content-Type', 'text/plain');
231+
res.end('Internal Server Error');
232+
}
233+
234+
console.error('Error in middleware(s): %s', err.stack);
235+
return;
230236
}
237+
231238
child(req, res);
232239
}
233240

0 commit comments

Comments
 (0)