Medium-severity reentrancy vulnerability in the _claimPlenty function of the Silo contract. The vulnerability arises from an external call to sopToken.safeTransfer preceding the modification of state variables, potentially exposing the contract to reentrancy attacks.
The vulnerability stems from the sequence of operations in the _claimPlenty function, where tokens are transferred using sopToken.safeTransfer before deleting s.a[account].sop.plenty. This order of operations opens up the possibility of reentrancy attacks, as external calls can be manipulated to re-enter the function before the delete operation is completed.
Code Snippet:(contracts/beanstalk/silo/SiloFacet/Silo.sol#154-164)
Exploit Scenario
An attacker owning a malicious contract could exploit this vulnerability by triggering a reentrancy attack through a fallback function:
If the sopToken.safeTransfer call in _claimPlenty triggers the attacker's fallback function, it could potentially re-enter the vulnerable contract before the delete operation, leading to unexpected state manipulation.
The impact of this vulnerability is substantial, warranting a "High" severity rating. A successful exploitation of the reentrancy vulnerability in the _claimPlenty function could lead to severe consequences. An attacker could manipulate the contract's state during execution, potentially resulting in unauthorized access to funds, unexpected contract behavior, or even a complete compromise of the contract's integrity. Considering the financial nature of the transactions involved, the potential for significant loss is high.
Manual review and slither.
Apply Check-Effects-Interactions Pattern: Modify the _claimPlenty function to follow the "check-effects-interactions" pattern, ensuring that state modifications occur before any external calls. Specifically, consider deleting s.a[account].sop.plenty before executing sopToken.safeTransfer.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.