Skip to content

Commit ce8cd7a

Browse files
committed
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 e265200 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.
1 parent ff92fbf commit ce8cd7a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/validation.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -3135,6 +3135,12 @@ static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidation
31353135
if (pindex->nTx != 0) return true; // This is a previously-processed block that was pruned
31363136
if (!fHasMoreWork) return true; // Don't process less-work chains
31373137
if (fTooFarAhead) return true; // Block height is too high
3138+
3139+
// Protect against DoS attacks from low-work chains.
3140+
// If our tip is behind, a peer could try to send us
3141+
// low-work blocks on a fake chain that we would never
3142+
// request; don't process these.
3143+
if (pindex->nChainWork < nMinimumChainWork) return true;
31383144
}
31393145
if (fNewBlock) *fNewBlock = true;
31403146

0 commit comments

Comments
 (0)