Closed code423n4 closed 1 year ago
dmvt marked the issue as primary issue
RedVeil marked the issue as disagree with severity
RedVeil marked the issue as sponsor confirmed
dmvt marked issue #581 as primary and marked this issue as a duplicate of 581
dmvt marked the issue as not a duplicate
dmvt marked the issue as nullified
Lines of code
https://github.com/code-423n4/2023-01-popcorn/blob/dcdd3ceda3d5bd87105e691ebc054fb8b04ae583/src/vault/adapter/abstracts/AdapterBase.sol#L173-L185 https://github.com/code-423n4/2023-01-popcorn/blob/dcdd3ceda3d5bd87105e691ebc054fb8b04ae583/src/vault/adapter/abstracts/AdapterBase.sol#L192-L204
Vulnerability details
Impact
A loss of as little of 1 "wei" will prevent a withdrawal/redeem transaction from executing.
Proof of Concept
Let's have a look step by step at what happens when withdrawing.
Yearn vault might take funds from strategy to withdraw; it can happen with a loss; the loss is then deducted from the number of assets to transfer back to the adapter. The number of assets transferred from yearn will now be lower than the number of assets expected when calling
withdraw()
. The IERC20(asset()).safeTransfer(receiver, assets) will fail, funds will not be withdrawable.The same issue happens when calling
redeem()
.Tools Used
Manual review
Recommended Mitigation Steps
Yearn returns the number of assets transferred when calling withdraw. This could be used to transfer the right number of assets. Please also note: Fixing this issue will not prevent withdrawal with a loss above 0.01% to fail. See the corresponding issue
Funds might not be recoverable from vault blocking withdrawal and pause
.warning: When solving the issue, it's important to check for burned yearn vault shares. In a case where the vault doesn't have enough tokens to transfer back (because of some tokens locked in strategies), the yearn vault will not burn all the shares, contrary the popcorn vault will burn all the shares. The popcorn vault will have to adjust the burned amount or revert. A user could retry with a smaller amount.