You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we received a block, OnNewBlock will be called to add the block.
321 private VerifyResult OnNewBlock(Block block)
322 {
323 if (block.Index <= Height)
324 return VerifyResult.AlreadyExists;
325 if (block.Index - 1 > Height)
326 {
327 AddUnverifiedBlockToCache(block);
328 return VerifyResult.UnableToVerify;
329 }
330 if (block.Index == Height + 1)
331 {
332 if (!block.Verify(currentSnapshot))
333 return VerifyResult.Invalid;
334 block_cache.TryAdd(block.Hash, block);
335 block_cache_unverified.Remove(block.Index);
336 // We can store the new block in block_cache and tell the new height to other nodes before Persist().
337 system.LocalNode.Tell(Message.Create(MessageCommand.Ping, PingPayload.Create(Singleton.Height + 1)));
338 Persist(block);
339 SaveHeaderHashList();
340 if (block_cache_unverified.TryGetValue(Height + 1, out LinkedList<Block> unverifiedBlocks))
341 {
342 foreach (var unverifiedBlock in unverifiedBlocks)
343 Self.Tell(unverifiedBlock, ActorRefs.NoSender);
344 block_cache_unverified.Remove(Height + 1);
345 }
346 }
347 return VerifyResult.Succeed;
348 }
If the block index is bigger than current block height plus 1, it will be added to unverified cache directly by calling AddUnverifiedBlockToCache.
Specifically, an attacker can keep sending blocks with large block index to flood the block_cache_unverified and cause the node Out-of-Memory. Further more, since the block_cache_unverified stores blocks with same index but different hashes into a LinkedList. Attacker can also flood the node with blocks that has same index but different hashes.
Do you have any solution you want to propose?
Add a size limit to block_cache_unverified.
Neo Version
Neo 3
Where in the software does this update applies to?
Ledger
P2P (TCP)
The text was updated successfully, but these errors were encountered:
ShawnYun
changed the title
Add check when received a block, and add a size limit to block_cache_unverified.
Add a size limit to block_cache_unverified.
Aug 20, 2020
Summary or problem description
If we received a block,
OnNewBlock
will be called to add the block.If the block index is bigger than current block height plus 1, it will be added to unverified cache directly by calling AddUnverifiedBlockToCache.
Specifically, an attacker can keep sending blocks with large block index to flood the block_cache_unverified and cause the node Out-of-Memory. Further more, since the block_cache_unverified stores blocks with same index but different hashes into a LinkedList. Attacker can also flood the node with blocks that has same index but different hashes.
Do you have any solution you want to propose?
Neo Version
Where in the software does this update applies to?
The text was updated successfully, but these errors were encountered: