SAFEAPPROVE() MAY REVERT FUNCTIONS #112
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2022-05-sturdy/blob/78f51a7a74ebe8adfd055bdbaedfddc05632566f/smart-contracts/LidoVault.sol#L102
https://github.com/code-423n4/2022-05-sturdy/blob/78f51a7a74ebe8adfd055bdbaedfddc05632566f/smart-contracts/ConvexCurveLPVault.sol#L146
Vulnerability details
SAFEAPPROVE() MAY REVERT FUNCTIONS
In
_depositToYieldPool()
, in the vaults contracts,safeApprove()
from the OpenZeppelin’s SafeERC20 library is used to give allowance to the Lending Pool address to transfer the amount to be deposited.However, the safeApprove function prevents changing an allowance between non-zero values to mitigate a possible front-running attack. It reverts if that is the case. Instead, the
safeIncreaseAllowance
andsafeDecreaseAllowance
functions should be used. Comment from the OZ library for this function:If the existing allowance is non-zero (ie if a user deposits a second time or more), then
safeApprove()
will revert causing the user’s token deposits to fail, leading to denial-of-service.Impact
Medium
Tools Used
Manual Analysis
Recommended Mitigation Steps
Use
safeIncreaseAllowance()
instead ofsafeApprove()
.The text was updated successfully, but these errors were encountered: