This repository has been archived by the owner on May 26, 2023. It is now read-only.
BlueBerryBank.withdrawLend
function, it is possible that extra amount, which is the difference between withdrawn amount from soft vault and position's underlyingAmount
, remains in BlueBerryBank
contract without belonging to anyone
#206
rbserver
high
When calling
BlueBerryBank.withdrawLend
function, it is possible that extra amount, which is the difference between withdrawn amount from soft vault and position'sunderlyingAmount
, remains inBlueBerryBank
contract without belonging to anyoneSummary
When the
BlueBerryBank.withdrawLend
function is called, the withdrawn amount from the soft vault can be bigger than the position'sunderlyingAmount
. Such extra amount would remain in theBlueBerryBank
contract without belonging to anyone.Vulnerability Detail
When calling the
BlueBerryBank.withdrawLend
function, ifwAmount
is from thebank.softVault
, theSoftVault.withdraw
function would executecToken.redeem(shareAmount)
, and it is possible that suchwAmount
is bigger thanpos.underlyingAmount
. When this happens,wAmount
is set topos.underlyingAmount
because theBlueBerryBank.withdrawLend
function executeswAmount = wAmount > pos.underlyingAmount ? pos.underlyingAmount : wAmount
. Then, thewAmount
are distributed to the treasury and eventually to the user. However, the extra amount that is the difference between thewAmount
from thebank.softVault
andpos.underlyingAmount
remains in theBlueBerryBank
contract without belonging to anyone.Impact
As described in the Vulnerability Detail section, the extra amount that is the difference between the withdrawn amount from the soft vault and the position's
underlyingAmount
would remain in theBlueBerryBank
contract without belonging to anyone. Thus, such extra amount is lost.Code Snippet
https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/BlueBerryBank.sol#L669-L704
https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/vault/SoftVault.sol#L94-L123
Tool used
Manual Review
Recommendation
The
BlueBerryBank.withdrawLend
function can be updated to transfer the described extra amount to a trusted party for preventing the loss of such amount.Duplicate of #109
The text was updated successfully, but these errors were encountered: