A liquidator can repay the smaller debt position to fully liquidate a position and receive the full collateral
Summary
An incorrect full liquidation of a position can occur by repaying only the token with the smaller debt, enabling a liquidator to receive the entire collateral and the protocol to accrue bad debt.
Vulnerability Detail
When a liquidatable position with multiple borrowed tokens (e.g. USDC and ICHI) is due for liquidation, a liquidator can repay the debt of the token with the smaller debt to fully liquidate the position and gain all wrapped LP tokens and isolated collateral.
This issue is caused by using the repaid share to determine the amount of collateral to be returned to the liquidator. share represents the repaid share of the given debt token (debtToken) and not the share of the total debt of the position.
Contrary to the Alpha Homora protocol, which uses amountPaid instead of share (see HomoraBank.sol#L459-L465).
Copy the test file into test/liquidate.test.ts and run yarn hardhat test --grep "should be able to liquidate full position by only repaying smaller debt token".
The test case demonstrates how a liquidator can just repay the smaller debt position (from a user who borrowed USDC and ICHI) to liquidate the position fully and receives all of the wrapped LP token collateral as well as the isolated collateral.
Impact
The incorrect full liquidation of a position by repaying only the smaller debt token causes the protocol to accrue bad debt.
berndartmueller
high
A liquidator can repay the smaller debt position to fully liquidate a position and receive the full collateral
Summary
An incorrect full liquidation of a position can occur by repaying only the token with the smaller debt, enabling a liquidator to receive the entire collateral and the protocol to accrue bad debt.
Vulnerability Detail
When a liquidatable position with multiple borrowed tokens (e.g. USDC and ICHI) is due for liquidation, a liquidator can repay the debt of the token with the smaller debt to fully liquidate the position and gain all wrapped LP tokens and isolated collateral.
This issue is caused by using the repaid
share
to determine the amount of collateral to be returned to the liquidator.share
represents the repaid share of the given debt token (debtToken
) and not the share of the total debt of the position.Contrary to the Alpha Homora protocol, which uses
amountPaid
instead ofshare
(see HomoraBank.sol#L459-L465).Test case
To demonstrate this issue, please use the provided test case at https://gist.github.com/berndartmueller/d34ce2b3708975e6b8271244cd586dfd.
Copy the test file into
test/liquidate.test.ts
and runyarn hardhat test --grep "should be able to liquidate full position by only repaying smaller debt token"
.The test case demonstrates how a liquidator can just repay the smaller debt position (from a user who borrowed USDC and ICHI) to liquidate the position fully and receives all of the wrapped LP token collateral as well as the isolated collateral.
Impact
The incorrect full liquidation of a position by repaying only the smaller debt token causes the protocol to accrue bad debt.
Code Snippet
BlueBerryBank.sol#L523-L527
Tool used
Manual Review
Recommendation
Consider using
amountPaid
instead ofshare
to determine the amount of collateral for the liquidator.Duplicate of #127