Rebase/FoT tokens are not supported as isolated collateral
Summary
The BlueBerryBank.lend function does not account for rebase/FoT tokens.
Vulnerability Detail
The SoftVault and HardVault contracts are already well prepared to handle rebase/FoT tokens properly. However, the BlueBerryBank.lend function does not account for rebase/FoT tokens and will not work properly with them.
As seen in lines 637-641, amount of the ERC-20 token is transferred from the pos.owner to the BlueBerryBank contract. From this amount, a deposit fee is decremented, and the remaining amount is deposited into the SoftVault or HardVault contract.
However, if the used token is a rebase/FoT ERC-20 token, the received token amount does not reflect the actual amount of tokens transferred. This leads to the incorrect amount of tokens being deposited and accounted for.
While the Blueberry protocol has whitelisting mechanisms in place to restrict the use of arbitrary ERC-20 tokens as isolated collateral, rebase/FoT tokens were likely intended to be supported as isolated collateral due to their support in the SoftVault and HardVault contracts.
Impact
Rebase/FoT tokens are not supported as isolated collateral and can not be used as isolated collateral without incurring accounting issues.
berndartmueller
medium
Rebase/FoT tokens are not supported as isolated collateral
Summary
The
BlueBerryBank.lend
function does not account for rebase/FoT tokens.Vulnerability Detail
The
SoftVault
andHardVault
contracts are already well prepared to handle rebase/FoT tokens properly. However, theBlueBerryBank.lend
function does not account for rebase/FoT tokens and will not work properly with them.As seen in lines 637-641,
amount
of the ERC-20 token is transferred from thepos.owner
to theBlueBerryBank
contract. From thisamount
, a deposit fee is decremented, and the remaining amount is deposited into theSoftVault
orHardVault
contract.However, if the used
token
is a rebase/FoT ERC-20 token, the received token amount does not reflect the actual amount of tokens transferred. This leads to the incorrect amount of tokens being deposited and accounted for.While the Blueberry protocol has whitelisting mechanisms in place to restrict the use of arbitrary ERC-20 tokens as isolated collateral, rebase/FoT tokens were likely intended to be supported as isolated collateral due to their support in the
SoftVault
andHardVault
contracts.Impact
Rebase/FoT tokens are not supported as isolated collateral and can not be used as isolated collateral without incurring accounting issues.
Code Snippet
BlueBerryBank.sol#L637-L641
SoftVault.sol#L76
As mentioned above, the
SoftVault
contract calculates the actual amount of tokens received after the transfer in line 75.Tool used
Manual Review
Recommendation
Consider calculating the delta of the token balance before and after the transfer and use this delta value as the
amount
to lend out.Duplicate of #153