20,000 USDC
View results
Submission Details
Severity: high

Potential reentrancy without following CEI pattern

Summary

Potential reentrancy without following CEI pattern or reentrancy attack protection

Vulnerability Details

https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Staking.sol#L38-L42
https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Staking.sol#L53-L58

balances[msg.sender] += _amount

effect happens after token transfer, which is easy to attack in this pattern

Impact

May lead to reentrancy attack if token has callback or simply write a malicious contract to reenter the function and drain the pool

Tools Used

Manual Review

Recommendations

follow check-effect-interaction pattern or use nonreentrant modifier from openzeppelin

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.