Open Flavien opened 8 years ago
Interesting, is it bad data that is being sent? It would be useful to have a payload to see what is is, and incorporate into tests.
We may need to handle this check https://github.com/bitpay/bitcore-p2p/blob/master/lib/messages/commands/addr.js#L48 better.
Here is the payload:
Is this accurate?
> var buf = new Buffer(new Uint8Array([1,42,233,205,86,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,128,8,124,7,71,157,0,0,0,0]));
> buf.toString('hex');
'012ae9cd56010000000000000000000000000000000000ffff80087c07479d00000000'
Yes that's correct.
So it looks it's parsed with:
[ { services: <BN: 1>,
ip:
{ v6: '0000:0000:0000:0000:0000:ffff:8008:7c07',
v4: '128.8.124.7' },
port: 18333,
time: Wed Feb 24 2016 12:32:26 GMT-0500 (EST) } ]
And has 4 bytes remaining (which may or may not be of concern).
Well, it is of concern to Bitcore as it checks that the buffers has been completely read, and that causes Object.checkFinished
to throw an exception.
Any progress on fixing this? This is a serious blocker for us.
It doesn't look like there is an issue parsing the info, as this matches up with https://en.bitcoin.it/wiki/Protocol_documentation#addr with the exception of the last four bytes:
01 - one addr
2ae9cd56 - time
0100000000000000 - services
00000000000000000000ffff80087c07 - ip address
479d - port
00000000 - ?
Well, I don't know whether there is an issue parsing the info, but I do know that receiving an invalid message shouldn't crash the process. That's a pretty obvious DoS vulnerability.
There are foreseeable other parsing and transaction/block validation issues, and connecting to a trusted peer is often used: https://github.com/bitpay/bitcore-p2p/blob/master/docs/pool.md#trusted-peers
Though we could certainly improve the robustness.
Using trusted peers defeats the purpose of Bitcoin.
It shouldn't be very hard to add proper error handling so that when a parsing error occurs, the message is just ignored, instead of crashing the whole process.
this makes my code crash also
I have encountered a similar problem, I still don't know how to solve it.https://github.com/bitpay/bitcore/issues/2183
I use this simple code:
However, after a minute or two, I get the following exception and the script crashes:
How to handle the error and carry on?