DeFiHardhat
35,000 USDC
View results
Submission Details
Severity: high
Invalid

Reeantrancy Vulnerability `_claimPlenty` in `Silo.sol`

Summary

High-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.

Vulnerability Details

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.

function _claimPlenty(address account) internal {
// Plenty is earned in the form of the non-Bean token in the SOP Well.
uint256 plenty = s.a[account].sop.plenty;
IWell well = IWell(s.sopWell);
IERC20[] memory tokens = well.tokens();
IERC20 sopToken = tokens[0] != C.bean() ? tokens[0] : tokens[1];
sopToken.safeTransfer(account, plenty);
delete s.a[account].sop.plenty;
emit ClaimPlenty(account, address(sopToken), plenty);
}
}

Exploit Scenario with fallback function:

function fallback() external {
// Re-enter the vulnerable contract
vulnerableContract.claimPlenty(msg.sender);
}

Impact

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.

Tools Used

Manual Review

Recommendations

Change order of operations to avoid reentrancy.

Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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