Skip to content
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

[NET] Invalid blocks from forks stored on disk fix + blocks DoS spam filter. #803

Conversation

furszy
Copy link

@furszy furszy commented Jan 26, 2019

This PR mitigates the following problems:

  1. Storage of invalid PoS/zPoS blocks from forked chains.
  2. Blocks spam filtering.

Thanks to @random-zebra for the team work on this topic.

This work will be properly detailed on the next days of QA.

loop through forked blocks fix

Invalid blocks from forks stored on disk Fix + Blocks DoS spam filter

minor re organization

minor cosmetic changes

comments
@ghost ghost assigned furszy Jan 26, 2019
@ghost ghost added the review label Jan 26, 2019
@furszy furszy force-pushed the invalid_blocks_storage_and_blocks_DoS_spam_filter branch from 66ed1e6 to c2e5459 Compare January 26, 2019 21:29
src/main.cpp Show resolved Hide resolved
src/main.cpp Show resolved Hide resolved
src/main.cpp Show resolved Hide resolved
src/main.cpp Outdated Show resolved Hide resolved
Copy link

@meyer9 meyer9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


src/main.cpp Show resolved Hide resolved
src/main.cpp Show resolved Hide resolved
@Fuzzbawls Fuzzbawls added this to the 3.2.0 milestone Jan 31, 2019
@Fuzzbawls Fuzzbawls added High Priority Block Storage Validation Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes labels Jan 31, 2019
@PIVX-Project PIVX-Project deleted a comment from jonspock Jan 31, 2019
@furszy
Copy link
Author

furszy commented Feb 1, 2019

Yeah cool @cevap 👍 , we did it too. Preparing the final report and a new test suite that contains an expanded coverage of the characteristics of our blockchain. Hopefully will be ready soon.

The published vulnerability report is just the tip of this, not really covering our full specs.

@pwte
Copy link

pwte commented Feb 4, 2019

I tested your code main.cpp.zip on the Safeinsure blockchain, which contains this exception, with bootstrap and does not work properly, make the infinite loop!
debug.zip

@furszy
Copy link
Author

furszy commented Feb 4, 2019

Sorry @pwte , i cannot download external files or check other blockchain code. PIVX has plenty of forks, impossible to know what everyone is doing.
If you have an issue running it on PIVX, send the logs here and will check them. Or well, write what you found on a code's review.

Here it's working fine the PR and solves the base attack scenarios (still a work in progress and lots of tests that needs to be done)

@pwte
Copy link

pwte commented Feb 4, 2019

Sorry @pwte , i cannot download external files or check other blockchain code. PIVX has plenty of forks, impossible to know what everyone is doing.
If you have an issue running it on PIVX, send the logs here and will check them. Or well, write what you found on a code's review.

Here it's working fine the PR and solves the base attack scenarios (still a work in progress and lots of tests that needs to be done)

You just can just look on the logs(debug.log)
You tried with bootstrap on PIVX blockchain?

@Mrs-X
Copy link

Mrs-X commented Feb 6, 2019

@pwte last night I bootstrapped a PIVX wallet without problems, so your exception is most probably related to your changes of the code.

@pwte
Copy link

pwte commented Feb 6, 2019

@pwte last night I bootstrapped a PIVX wallet without problems, so your exception is most probably related to your changes of the code.

I'm glad to hear that.
The test was OK because so far the PIVX blockchain did not have the real situation where the transaction that generated the stake was spent on the fork.
I tested 19 blockchains(PIVX forks) and I found this exception only at safeinsure
Look at the logs above!

@pwte
Copy link

pwte commented Feb 6, 2019

Everything you've done until now it's theoretical, you haven't tested on real situations

@furszy
Copy link
Author

furszy commented Feb 6, 2019

Actually, I have. This is not theoretical at all, we have a new test suite that it's running most of the possible scenarios. And it's working fine using this code.

Only zerocoin scenarios left to be completed and will be pushed here too.

And again, will not open logs from other projects. Impossible to know what code you have there. If you can replicate it on PIVX paste the log here, no files.

@furszy furszy force-pushed the invalid_blocks_storage_and_blocks_DoS_spam_filter branch from d90d307 to 0d49570 Compare February 8, 2019 14:10
j00v added a commit to j00v/MNPCoin that referenced this pull request Feb 12, 2019
yurykk pushed a commit to NewCapital/TWINS-Core that referenced this pull request Feb 15, 2019
preparing 3.2.0.5
Addresses https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-6250

Merge PIVX-Project/PIVX#803, addressing fake stake attack

https://medium.com/@dsl_uiuc/fake-stake-attacks-on-chain-based-proof-of-stake-cryptocurrencies-b8b05723f806

# Conflicts:
#	src/main.cpp
PR #803 Fake Stake merge
Update "fake stake" patch
Updating PR#803 from PIVX-Core addressing Fake Stake attack

# Conflicts:
#	src/main.cpp
@random-zebra random-zebra self-assigned this Feb 15, 2019
src/main.cpp Outdated Show resolved Hide resolved
@furszy furszy changed the title [WIP] [NET] Invalid blocks from forks stored on disk fix + blocks DoS spam filter. [NET] Invalid blocks from forks stored on disk fix + blocks DoS spam filter. Feb 24, 2019
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 61a6ea7

@Fuzzbawls Fuzzbawls merged commit 61a6ea7 into PIVX-Project:master Feb 25, 2019
Fuzzbawls added a commit that referenced this pull request Feb 25, 2019
…ks DoS spam filter.

61a6ea7 AcceptBlock() for-each loops variables moved to const (furszy)
e1974d2 AcceptBlock() check for double spent serials only on main chain flag. (furszy)
babdfb0 remove extra debug lines in AcceptBlock (random-zebra)
a9178bc AcceptBlock: contextual zcspend check on main chain (random-zebra)
0d49570 AcceptBlock() block stored log removed (furszy)
b749217 Fix bug on AcceptBlock when pindex is null (random-zebra)
45883b9 AcceptBlock() invalid isBlockFromFork flag (furszy)
6a16049 AcceptBlock() reject blocks double spending the coin stake input inside the same block (furszy)
da1b683 block spam filter, validate non null nodestate (furszy)
84de55a AcceptBlock() isBlockFromFork flag not contemplating prev blocks from forks fixed (furszy)
4219339 AcceptBlock() - not accept blocks from a forked chain that exceed the max reorg limit (furszy)
47759e1 AcceptBlock(), reject invalid PoS stake (furszy)
e237823 validate non null pfrom on blockspamfilter check (furszy)
c2e5459 AcceptBlock(), serial double spend on the same block validation (furszy)
3f50919 zPoS validations of forked chains before store them + inputs check on prev split main chain (furszy)
64804b4 Invalid blocks from forks stored on disk fix + blocks DoS spam filter. (furszy)

Tree-SHA512: 6c5a7fda3eb81dc8b030c9ba624e5101f552ef9cecc839a79237b705c314171c0e9c66ecd8bfd207081c6759272140cf3bdf0da7af6ac4695f0c09b74fb1ba45
@ghost ghost removed the review label Feb 25, 2019
@Fuzzbawls Fuzzbawls removed Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes labels Mar 23, 2019
carebitcoin added a commit to carebitcoin/carebitcoin that referenced this pull request Apr 9, 2019
adam-waldenberg pushed a commit to unigrid-project/daemon that referenced this pull request Jun 27, 2019
@furszy furszy deleted the invalid_blocks_storage_and_blocks_DoS_spam_filter branch May 27, 2023 01:57
dekm pushed a commit to HUZU-Project/HUZU that referenced this pull request Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants