Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 1.36 KB

Not following the Checks-Effects-Interactions pattern.md

File metadata and controls

30 lines (24 loc) · 1.36 KB

The finalizeGrant function of the Fund contract is setting the grant.complete storage variable after a token transfer.

Solidity recommends the usage of the Check-Effects-Interaction Pattern to avoid potential security issues, such as reentrancy.

The finalizeGrant function can be used to conduct a reentrancy attack, where the token transfer in line 129 can call back again the same function, sending to the admin multiple times an amount of fee, before setting the grant as completed.

In this way the grant.recipient can receive less than expected and the contract funds can be drained unexpectedly leading to an unwanted loss of funds.

Recommendation:

Consider always following the “Check-Effects-Interactions” pattern, thus modifying the contract’s state before making any external call to other contracts.


Slide Screenshot

088.jpg


Slide Text

  • OpenZeppelin Audit Open Gamma Finding M07
  • Timing
  • High Severity
  • Token Transfer -> State Update => Fund Drained
  • Follow CEI
  • Use Reentrancy Guard

References


Tags