Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Latest commit

 

History

History

denial_of_service

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Denial of Service

A malicious contract can permanently stall another contract by failing in a strategic way. In particular, contracts that bulk perform transactions or updates using a for loop can be DoS'd if a call to another contract or transfer fails during the loop.

Attack Scenarios

  • Auction contract where frontrunner must be reimbursed when they are outbid. If the call refunding the frontrunner continuously fails, the auction is stalled and they become the de facto winner.

  • Contract iterates through an array to pay back its users. If one transfer fails in the middle of a for loop all reimbursements fail.

  • Attacker spams contract, causing some array to become large. Then for loops iterating through the array might run out of gas and revert.

Examples

Mitigations

  • Favor pull over push for external calls
  • If iterating over a dynamically sized data structure, be able to handle the case where the function takes multiple blocks to execute. One strategy for this is storing iterator in a private variable and using while loop that exists when gas drops below certain threshold.

References