-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Discussion: easy to trigger 'error' events on tls server connections, DoS vector || caveat emptor? #1848
Comments
I don't understand the title. It implies the 'error' event is emitted on the server instance, when they're clearly emitted on the connection instance. Or is that a suggested change? |
This is a really good question and one that I struggle with. Here are my thoughts based on having to deal with this middle ground for modules. For modules I take this approach. Does the code make a promise of security stated or commonly accepted. If this promise can be broken in some way then it is in fact a vulnerability. The other side of the coin is that code can be used improperly. For those we don't issue an advisory but provide a secure usage recommendation. (the result is usually documentation is updated to inform of secure usage). It seems to me we have historical precedence based on HTTP that we will not blow up when encountering an error parsing the protocol and situations in which we will blow up are documented appropriately. Given what is a commonly accepted promise, if it's not documented that it will blow up in this situation then commonly it will be implemented in this fashion and would be considered an attack on availability creating a denial of service condition. Lastly I think this one should follow security protocol and at least be labeled in the change log as a security impacting change (either if documentation is updated to say that we don't promise to not blow up on protocol violations or if we fix it to not blow up in this situation). That way people know to look at their code either way and make the decisions as to how to take action. |
Another way of handling that error: tlsServer.on('clientError', function (err, conn) {
conn.destroy();
}); What if we refrain from throwing these errors and push users to use these error handlers if they are interested in socket errors? |
The main thing that I don't want to miss is the ability to handle error myself. Whatever the resolution of this issue may be, it should still be possible to have the current behavior. |
@seishun: you're quite right regarding the title, I've attempted to correct it |
I'm leaning towards more of a caveat emptor because although this is definitely a DoS vector if handled improperly.. I think it should be well known that not handling |
@rvagg Thanks for opening this issue and writing the detailed description. I appreciate your help very much.
So this is not specific only to As for the tls error, at the first time I missed to be aware that
|
Speaking as a user, I would expect node.js/io.js to prevent any single user from crashing an entire application by throwing the error. It is okay to emit it on the connection / socket, but it shouldn't bubble up. I know that is how the EventEmitter works, but I would expect it to gracefully handle an error by a third party. I think if both examples of code on nodejs.org are vulnerable to unhandled exceptions, there is an issue. |
@rvagg As for this: tls.createServer(options, function(clientSocket) {
clientSocket.on('error', function() {})
}).listen(1443); The same is applicable to net.createServer(function(from) {
from.on('error', function(e) {
console.log(e);
});
...
}).listen(port); Though a |
I guess we don't have any resolution, are we? |
I'm for shelving this and just closing it. It's been out in the wild and no-one has complained, and we can't seem to decide. |
+1 |
1 similar comment
+1 |
Closing due to the +1's above for closing it. If that is premature, please re-open and accept my apologies :] |
This is something that's been floating around in email amongst the io.js TC for a little while now and we don't have a clear agreement on how we want to approach this or if we even want to do anything about it at all. So this is now open for public discussion and we'll be interested to hear feedback from @nodejs/collaborators and the new @nodejs/tsc.
While investigating #1595, @shigeki came across an interesting case where it's trivial to kill a tls server (not https) that's not well crafted.
server.js
client.js
i.e. by writing directly to the socket rather than the encrypted channel the client can force an
'error'
event on the server connection (clientSocket
, not the server itself).Of course, if you simply handle the
'error'
event onclientSocket
then you catch it:Some think that this may be classifiable as a DoS vulnerability, while others question whether this should even be considered a bug.
I think it comes down to how you view TLS as a "protocol". Is it like HTTP in that it sits on top of TCP and is a parsed and managed protocol that provides a higher level of abstraction to the user? Or is it closer to TCP in that it's a raw protocol and can be easily abused and you don't get many guarantees about protocol handling? The HTTP handling in io.js/Node.js provides a nice encapsulation of per-connection parsing, the client can do something wrong and move outside of the bounds of the protocol and it's just disconnected without that bubbling up to the server code. However with the current TLS API a client that isn't talking within the bounds of the protocol will cause an error that bubbles all the way up and if
'error'
event is not handled on each connection it will bring down the entire process.With HTTP you can do this:
and then this:
doesn't get through to the handler at all because the client is misbehaving and is therefore simply disconnected.
As an aside, @shigeki did the right thing with this, he had a concern that this could be abused in the real-world and took it directly to the TC to discuss before raising it publicly. We've had some vigorous discussions about this and haven't agreed that it should be categorised as a security concern but if we had then it would have been handled discreetly and a fix pushed out with a matter of urgency as well as filling a CVE for it. So, if you find something like this, please take it to email. We'll have a proper security@ email soon enough but for now just find someone you know and trust on the list of TC members and contact them.
The text was updated successfully, but these errors were encountered: