unit-e icon indicating copy to clipboard operation
unit-e copied to clipboard

Validate full blocks before storing them to disk and maybe ban peers

Open Gnappuraz opened this issue 6 years ago • 3 comments

Bitcoin implementation is a bit loose when performing validation before storing blocks to disk. This behavior is defendable since it can check the proof of stake correctness. Whenever a new block is received the following happens:

ProcessNewBlock() -> AcceptBlock() -> store on disk

if any of those calls fail the block is not stored but the peer is not punished (as it should). Unfortunately there is no check for signature correctness nor for the stake to not be already spent. Those checks are happening at a later time when:

ConnectBlock() ->  CheckTxInputs()

checks for the scriptSig validity (executing it).

Since we can't rely on PoW to guard our resources we have to validate thoroughly any block before storing it to disk and in case somebody relays something invalid we should proceed and ban him, as it's expected to perform all the validations before relaying a block.

Gnappuraz avatar Nov 21 '18 15:11 Gnappuraz

Good catch! To be implemented/verified with the help of @amiller. Who disclosed disk attacks in some PoS currencies

thothd avatar Nov 21 '18 15:11 thothd

Some fixes / responses to the vulnerabilities:

  • https://www.dropbox.com/s/nw6uipvjxo0ujrs/NLC2-PoS-Vulnerabilities-20190124.pdf?dl=0
  • https://github.com/Galilel-Project/galilel/commit/1fe39e9ca036f915f27322dfb575da78c0163984

thothd avatar Jan 27 '19 12:01 thothd