Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAFEAPPROVE() MAY REVERT FUNCTIONS #112

Closed
code423n4 opened this issue May 15, 2022 · 2 comments · May be fixed by sturdyfi/code4rena-may-2022#8
Closed

SAFEAPPROVE() MAY REVERT FUNCTIONS #112

code423n4 opened this issue May 15, 2022 · 2 comments · May be fixed by sturdyfi/code4rena-may-2022#8
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")

Comments

@code423n4
Copy link
Contributor

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 and safeDecreaseAllowance functions should be used. Comment from the OZ library for this function:

safeApprove should only be called when setting an initial allowance, or when resetting it to zero. To increase and decrease it, use safeIncreaseAllowance and safeDecreaseAllowance

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 of safeApprove().

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels May 15, 2022
code423n4 added a commit that referenced this issue May 15, 2022
@sforman2000 sforman2000 added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label May 18, 2022
@HickupHH3
Copy link
Collaborator

I agree with the finding, but previous contests have marked it as low-risk (QA).
See:
code-423n4/2021-11-malt-findings#41
code-423n4/2022-01-sherlock-findings#269

Hence, downgrading to QA.

@HickupHH3 HickupHH3 added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Jun 3, 2022
@HickupHH3
Copy link
Collaborator

Grouping this with the warden’s QA report: #111

@HickupHH3 HickupHH3 added the duplicate This issue or pull request already exists label Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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")
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants