Closed c4-bot-10 closed 3 months ago
MarioPoneder marked the issue as primary issue
MarioPoneder marked the issue as satisfactory
MarioPoneder marked the issue as selected for report
MarioPoneder marked the issue as duplicate of #27
MarioPoneder marked the issue as not selected for report
MarioPoneder changed the severity to 3 (High Risk)
Lines of code
https://github.com/code-423n4/2024-07-benddao/blob/117ef61967d4b318fc65170061c9577e674fffa1/src/libraries/logic/VaultLogic.sol#L497
Vulnerability details
Impact
Vulnerable
VaultLogic::erc20TransferOutBidAmountToLiqudity
will cause incorrect accounting ofassetData
or DOS liquidation.Proof of Concept
In IsolateLogic.sol's auctions, when a bid is placed,
assetData.totalBidAmount
is increased with the bid amount erc20TransferInBidAmount(). When a bid is outbidded, the old bid is transferred out and in erc20TransferOutBidAmount(),assetData.totalBidAmount
is subtracted by the old bidAmount.The problem is
VaultLogic::erc20TransferOutBidAmountToLiqudity
will most likely causeassetData.totalBidAmount
to be incorrect because it falsely assumes the final debt amount (vars.totalBorrowAmount) will equal to the total bid amount(vars.totalBidAmount
).When a loan is liquidated post-auction, due to debt compounding and due to minBidDelta requirements, vars.totalBorrowAmount and vars.totalBidAmount will differ.
(https://github.com/code-423n4/2024-07-benddao/blob/117ef61967d4b318fc65170061c9577e674fffa1/src/libraries/logic/IsolateLogic.sol#L430)
In
VaultLogic.erc20TransferOutBidAmountToLiqudity
,vars.totalBorrowAmount
will be subtracted fromassetData.totalBidAmount
.(https://github.com/code-423n4/2024-07-benddao/blob/117ef61967d4b318fc65170061c9577e674fffa1/src/libraries/logic/VaultLogic.sol#L497)
(1) vars.totalBorrowAmount > vars.totalBidAmount;
assetData.totalBidAmout -= amount
might revert due to underflow, liquidation will fail.(2) vars.totalBorrowAmount < vars.totalBidAmount; assetData.totalBidAmount will be inflated.
Tools Used
Manual
Recommended Mitigation Steps
Consider change erc20TransferOutBidAmountToLiqudity with an extra input variable
totalBidAmount
.Assessed type
Error