At the end of the method, we will use erc20TransferOutBidAmountToLiqudity(vars.totalBorrowAmount) to reduce the totalBidAmout:
assetData.totalBidAmout -= vars.totalBorrowAmount
Using vars.totalBorrowAmount may be incorrect
Over time (borrowIndex increase), vars.totalBorrowAmount may be greater than vars.totalBidAmount
This will result in assetData.totalBidAmout being subtracted too much
Impact
assetData.totalBidAmout was incorrectly subtracted too much , which could lead to subsequent methods underflow
Recommended Mitigation
when have remainBidAmounts, don't use erc20TransferOutBidAmount() , it will reduce totalBidAmout
erc20TransferOutBidAmountToLiqudity() use totalBidAmount
function executeIsolateLiquidate(InputTypes.ExecuteIsolateLiquidateParams memory params) internal {
...
// transfer remain amount to borrower
if (vars.remainBidAmounts[vars.nidx] > 0) {
- VaultLogic.erc20TransferOutBidAmount(debtAssetData, tokenData.owner, vars.remainBidAmounts[vars.nidx]);
+ assetData.underlyingAsset.safeTransfer(tokenData.owner,vars.remainBidAmounts[vars.nidx]);
}
...
// bid already in pool and now repay the borrow but need to increase liquidity
- VaultLogic.erc20TransferOutBidAmountToLiqudity(debtAssetData, vars.totalBorrowAmount);
+ VaultLogic.erc20TransferOutBidAmountToLiqudity(debtAssetData, vars.totalBidAmount);
Lines of code
https://github.com/code-423n4/2024-07-benddao/blob/117ef61967d4b318fc65170061c9577e674fffa1/src/libraries/logic/IsolateLogic.sol#L464
Vulnerability details
Vulnerability details
When execute
isolateLiquidate()
, we will accountingtotalBidAmout
At the end of the method, we will use
erc20TransferOutBidAmountToLiqudity(vars.totalBorrowAmount)
to reduce thetotalBidAmout
:assetData.totalBidAmout -= vars.totalBorrowAmount
Using
vars.totalBorrowAmount
may be incorrect Over time (borrowIndex increase),vars.totalBorrowAmount
may be greater thanvars.totalBidAmount
This will result inassetData.totalBidAmout
being subtracted too muchImpact
assetData.totalBidAmout
was incorrectly subtracted too much , which could lead to subsequent methodsunderflow
Recommended Mitigation
totalBidAmout
erc20TransferOutBidAmountToLiqudity() use totalBidAmount