From 0e36912906640fdb007e0492b75c3f6a7b580ec6 Mon Sep 17 00:00:00 2001 From: indexzero Date: Thu, 8 Sep 2011 16:44:25 -0700 Subject: [PATCH] Fixed large DoS vector in the middleware implementation --- lib/node-http-proxy.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/node-http-proxy.js b/lib/node-http-proxy.js index 02aae9c..ea05ab1 100644 --- a/lib/node-http-proxy.js +++ b/lib/node-http-proxy.js @@ -222,12 +222,19 @@ exports.stack = function stack (middlewares, proxy) { handle = function (req, res) { var next = function (err) { if (err) { - throw err; - // - // TODO: figure out where to send errors. - // return error(req, res, err); - // + if (res._headerSent) { + res.destroy(); + } + else { + res.statusCode = 500; + res.setHeader('Content-Type', 'text/plain'); + res.end('Internal Server Error'); + } + + console.error('Error in middleware(s): %s', err.stack); + return; } + child(req, res); }