aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@chaincode.com>2017-10-06 14:11:43 -0400
committerSuhas Daftuar <sdaftuar@chaincode.com>2017-10-19 20:33:45 -0400
commitce8cd7a7da9174ab151172fc0ce97b5164637cf3 (patch)
tree61191a31eb8fb0c9ede4b1825c9161f97816e47c /src/validation.cpp
parentff92fbf24739a022eb677daab03c87c5e6971094 (diff)
Don't process unrequested, low-work blocks
A peer could try to waste our resources by sending us unrequested blocks with low work, eg to fill up our disk. Since e2652002b6011f793185d473f87f1730c625593b we no longer request blocks until we know we're on a chain with more than nMinimumChainWork (our anti-DoS threshold), but we would still process unrequested blocks that had more work than our tip. This commit fixes that behavior.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index d19521bd3c..866e0c9fba 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -3135,6 +3135,12 @@ static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidation
if (pindex->nTx != 0) return true; // This is a previously-processed block that was pruned
if (!fHasMoreWork) return true; // Don't process less-work chains
if (fTooFarAhead) return true; // Block height is too high
+
+ // Protect against DoS attacks from low-work chains.
+ // If our tip is behind, a peer could try to send us
+ // low-work blocks on a fake chain that we would never
+ // request; don't process these.
+ if (pindex->nChainWork < nMinimumChainWork) return true;
}
if (fNewBlock) *fNewBlock = true;