Skip to content

Commit 3acec38

Browse files
sdaftuarMarcoFalke
authored andcommitted
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. Github-Pull: #11458 Rebased-From: ce8cd7a
1 parent 0e9d04b commit 3acec38

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/validation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,6 +3120,12 @@ static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidation
31203120
if (pindex->nTx != 0) return true; // This is a previously-processed block that was pruned
31213121
if (!fHasMoreWork) return true; // Don't process less-work chains
31223122
if (fTooFarAhead) return true; // Block height is too high
3123+
3124+
// Protect against DoS attacks from low-work chains.
3125+
// If our tip is behind, a peer could try to send us
3126+
// low-work blocks on a fake chain that we would never
3127+
// request; don't process these.
3128+
if (pindex->nChainWork < nMinimumChainWork) return true;
31233129
}
31243130
if (fNewBlock) *fNewBlock = true;
31253131

0 commit comments

Comments
 (0)