hyperledger-labs / Scorex

Scorex 2.0 Core
Apache License 2.0
543 stars 115 forks source link

Banning peers for sending adversarially constructed messages #358

Closed kushti closed 4 years ago

kushti commented 4 years ago

This PR is introducing MaliciousBehaviorException indicating malicious behavior of a peer. Such exception is thrown if a peer tries to send wrong magic bytes (so a peer is from another network), or trying to declare length of a following-up buffer to be negative, or providing incorrect checksum for a message. This PR also contains some fixes for penalizing logic.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 46.984% when pulling 19bcf207778ec9bbd73a9e7bfcacb72965d90c23 on banning-peers into d7e57852389666b5121ae8796f223cfd872f11c6 on master.