-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node security release makes http-proxy crash #964
Comments
@fjakobs what strings are causing this to throw? Could you log the headers that are being set here? Would love a test case for this |
@jcrugzz I found this in the wild:
Not sure why someone would do this but is certainly should not crash the app. |
here you can see what node is expecting nodejs/node@7bef1b7#diff-9ef7b1e52407f06cd19696d2f726e498R241 |
easy to reproduce. This works on node 0.10.41 and throws in 0.10.42 var httpProxy = require('http-proxy');
var net = require("net");
var http = require("http");
var proxy = httpProxy.createProxyServer({target:'http://localhost:9000'});
proxy.on('error', function(err, req, res) {
console.log(err);
});
proxy.listen(8080);
var server = net.createServer(function(socket) {
socket.on("data", function(data) {
socket.write("HTTP/1.1 200 OK\n");
socket.write("Content-Type: ");
socket.write(new Buffer([0xfd, 0x40, 0x40]));
socket.write("\n");
socket.write("\n");
socket.write(JSON.stringify({
"name": "foo",
"version": "4.4.4"
}, null, 2));
socket.end();
});
});
server.listen(9000);
http.get("http://localhost:8080", function(res) {
process.exit();
}); on node 0.10.42
|
@fjakobs hmm yea thats kind of unfortunate that we are receiving invalid headers. I'd almost rather do this check ourselves to prevent the need for a |
Would you prefer sanitizing the headers or passing on the error? |
@fjakobs how do you feel about the behavior of ignoring bad headers? I guess we could make it an option to receive it as an error but I dont think the proxy server should have to care if its receiving bad headers from a client, it just doesnt pass them along since they are not spec compliant. What im thinking about is using that internal check they added to node core and using that as a signal to ignore the header. |
I am using latest Meteor and hitting something with the same signature. I am trying to figure out a workaround and you guys seem to have the best handle on this. Here is the stack dump:
A couple questions, this looks like an inbound request which crashes the server? I wanted to simply comment the throw but it appears that the respective code gets compiled into the node elf executable? Thanks in advance! |
Refining my question a little. So it looks like a request comes in, nothing necessarily particular about the request, but then on the response invalid characters are entered into the header? Would the following be a reasonable workaround to provide immediate relief ? i.e. I need to prevent a hard crash when hitting this error.
Thanks again! |
Sorry about the noise. It appears that the issue can occur on the receive and send side. I notified the Meteor folks that the issue exists on the receive side. This is pretty nasty as a crafted request brings the server down. |
@ppotoplyak if you want to rebase from this branch #965 id merge it until we can figure out a better way that doesnt de-opt from the try catch. |
@jcrugzz sure, if you are okay waiting until next week There is a worse problem on the incoming side. A similarly crafted request brings the node/Meteor process down. This is my workaround to prevent the process from terminating:
The malformed request will take an "Error: socket hang up" but the server will stay up. |
I'm experiencing the same problem, any news on this recently? |
Have the same problem with |
+1 |
The recent security release https://nodejs.org/en/blog/vulnerability/february-2016-security-releases/ of node.js makes header parsing much more strict:
Setting headers can throw now at https://github.com/nodejitsu/node-http-proxy/blob/master/lib/http-proxy/passes/web-outgoing.js#L86.
Here the change in node.js https://github.com/nodejs/node/blob/fab240a886b69ef9fa78573fc210c15cfe0018f0/lib/_http_outgoing.js#L309
I'm getting
The header content contains invalid characters
error and then I get an uncaught exception.Since I don't control the app being proxied and I can't wrap this call into a try/catch, this needs to be fixed in http-proxy.
The text was updated successfully, but these errors were encountered: