Withdrawal Pattern

Is there a withdrawal pattern in any of the OpenZeppelin contracts which protects against DOS (Denial of Service) attacks?

1 Like

I am not sure, maybe not.

1 Like

Hi @crypto_economics,

What do you mean by a withdrawal pattern and DOS attacks with a smart contract?

Pull over Push Payments (also known as the Withdrawal Pattern)

Navigate to this fund splitter contract on Github.

There are a few key takeaways from this contract.

First, There is a separation of function logic. The split() function handles the accounting and divides the msg.value sent with the transaction. Another function, withdraw() , allows accounts to transfer their balance from the contract to their account.

This pattern is also called the withdrawal pattern. It protects against re-entrancy and denial of service attacks

Hi @crypto_economics,

Please see: Reentrancy After Istanbul and https://docs.openzeppelin.com/contracts/3.x/api/payment#PullPayment

@abcoathup so that would protect against both Re-entrancy and DOS?

1 Like

Hi @crypto_economics,

It would protect against re-entrancy.

I assume you mean by denial of service is preventing a user from interacting with the contract as expected. e.g. self destruct, putting in a state that results in reverts. Appropriate testing and auditing should help to reduce this risk.

1 Like