-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Error: toString failed #7388
Comments
/cc @nodejs/buffer |
@nodejs/security |
I'll dig into this today |
It sounds like an allocation failure. Any chance there were core dumps on that system? |
I think it may be mitigated by using |
I'm not sure. How would I check for that?
Alright, I'm looking into that right now. |
@Alchemystic most likely you don't have them then. Node.js has to be running with |
@Alchemystic in initial message you mentioned traffic increase, I suspect that it should be around several gigabytes (2-3 or more). Does this match your data? |
I think it was more like 20 megabytes per second when our average was around 5. It just happened again 20 minutes ago so here's the spike from when it happened (it flatlined because we didn't start it back up): Here is the "network packets" graph: No spikes in disk bytes / cpu utilization. |
@Alchemystic this seems to be confirming my hypothesis. How many crashes did you get? |
@Alchemystic thank you for the data, btw. |
@indutny friend of @Alchemystic here :) Can you give me some insight into the maxPayload thing you mentioned above? I'm guessing you're referring to the clientside js where we declare our socket..and there's some sort of parameters or options we can set along with it right? Mind posting what that would look like if you can? |
Two days ago it would crash every other minute basically (100+ crashes). Been mostly down for the last day just trying to find various fixes for it. None of them worked, and it's been really difficult to try and test any other fixes after it stopped being a non-stop thing to only happening when we go online. |
interesting. |
And thank you for the replies, I guess I've been too focused on trying to relate all the info I have and forgot to say that I'm grateful for you guys getting involved and trying to help. |
Having core dumps would certainly help quite a lot. |
If you could explain a bit how to do what you've mentioned in your post earlier, I'd be more than happy to do it and post the results. |
Also, I'm not getting much by looking up the "maxPayload" option, or maybe I just don't understand how to set it. How would that fit in our current set up (the script in the main post)? |
@Alchemystic I have no idea how to propagate Regarding core dumps, they are pretty easy to enable. Let's say you start application with: node app.js Replacing this with: ulimit -c unlimited && node --abort_on_uncaught_exception app.js Will make node generate |
What version of ws are you using for the stacktrace in the OP? Line numbers don't match up w/ latest. |
Socket.io version 1.4.6 @indutny been running it like that for a while. Still no crash. Waiting for it though. |
@Alchemystic I think I figured out the reason, so there is no need for the core dump anymore. Thank you for trying it out, though! Please stay tuned as we are currently resolving this issue. |
Alright thank you. We've found a workaround to stop the crashes but I can't go into detail here until the "real" issue is resolved because it may put us at risk again. The attacker and one other person already asked for money for it saying they won't stop crashing it till we give them what they want, I wouldn't want them or others catch on to it. I will e-mail you about it. Thanks again for all the help. |
Here is a minimal test case to reproduce the issue on my machine: const crypto = require('crypto');
const buf = crypto.randomBytes(Math.pow(2, 28));
buf.toString(); |
Alright, the advisory is public now: https://nodesecurity.io/advisories/120 . The bug is in socket.io/ws, please update! |
major
,minor
, andpatch
labels to PRs, Issues #69~14.04.1-Ubuntu SMP Thu Jun 9 09:09:13 UTC 2016 x86_64 x86_64 x86_64 GNU/LinuxNode server using socket.io is getting hit by some kind of attack that makes it crash, with the error "toString failed". At first I thought I'm just trying to process some really long string sent via sockets by an user, but it's not, it crashes even without doing anything with the messages coming in from the socket events. The code below is the most barebones I could get the actual server while still having it be vulnerable to whatever this is. The "socketio-wildcard" was only added to this so I could see all the events sent in, but there is none when it's actually crashing, just a new connection opening then it goes down. It's definitely some sort of attack or exploit, cloning the server to a different IP made it stop, until after the new was released to the public (site put back online). There were also some spikes in traffic but they didn't coincide with the actual crashes so I'm gonna assume they were just some failed ddos attempts not related to this issue. Anyone encountered this before?
Code:
Error:
Full log of the output when crashing:
http://pastebin.com/EvAxGQj6
Couldn't do anymore logging because after some time the "attack" stopped, it used to keep going even after the server crashed, but right now it seems to be more "calculated" so to speak, stopping as soon as the server crashes, making it really difficult for me to debug anything.
The text was updated successfully, but these errors were encountered: