snarkOS icon indicating copy to clipboard operation
snarkOS copied to clipboard

[Bug] The pool operator can send a broken message over the network

Open ljedrz opened this issue 3 years ago • 2 comments

The following error was reported in Discord's #testnet-support:

Failed to get challenge request from <address>: Custom { kind: InvalidData, error: "Frame of length 1347703880 is too large." }

Where <address> was the address of their pool operator. This indicates a bug in the implementation of a pool-related network message.

Cc @julesdesmit

ljedrz avatar Mar 11 '22 16:03 ljedrz

1347703880 is 0x50545448, which should be interpreted as "HTTP".

This is caused by nodes accidentally connecting to RPC ports instead of P2P ports - the RPC server returns HTTP/1.1 400 Bad Request because the HTTP server couldn't understand binary traffic sent to it. The first 4 bytes are then interpreted as the frame length.

Thus, this should be an user error instead of protocol bugs.

HarukaMa avatar Jun 03 '22 09:06 HarukaMa

My primary concern was that something was broken in the new pool-related messages that the nodes were sending, but it turns out it's a very mild issue after all.

Thus, this should be an user error instead of protocol bugs.

Well, this is technically a protocol bug, and I don't think we should try to find out what the sender's intention was if they are not following the protocol, unless we were to e.g. add some magic bytes to all the messages (before the length).

IMO the best solution would be to move ChallengeRequest and ChallengeResponse variants out of enum Message, and to have those handshake-only messages prepended with the aforementioned "magic bytes" that would make it clear whether the protocol is followed or not.

ljedrz avatar Jun 08 '22 10:06 ljedrz

Not applicable to testnet3.

ljedrz avatar Sep 02 '22 13:09 ljedrz