Market in Singularity cannot be disabled using as a collateral (LTV=0) completely by (collateralizationRate to 0) while being borrowable.
a market in lending protocol works by having a collateralFactor (<1) that gives a user deposit value, for borrowing. The deposit while earning interest, also the collateral for borrowing at the same time.
However, there are assets, that is meant to work only as a borrowable asset, but not eligible for collateralization. For example, USDT in Aave (ETH-mainnet). This asset typically has an LTV (collateralFactor) of 0, such that they dont contribute to a user's borrowing ability.
However, in the design of Market.sol, collateralizationRate can only be set through setMarketConfig, which has the conditional checks that the new _collateralizationRate is a non-zero value.
if (_collateralizationRate > 0) {
require(
_collateralizationRate <= FEE_PRECISION,
"Market: not valid"
);
https://github.com/Tapioca-DAO/tapioca-bar-audit/blob/2286f80f928f41c8bc189d0657d74ba83286c668/contracts/markets/Market.sol#L233-L239
This is an issue could right now then the protocol cannot onboard a "USDT-type" asset, this is only borrowable but not intended to work as collateral.
While the operator can set the totalBorrowCap to 0 to sunset/stop new borrowing of a newly onboarded market, however consider there is some risk changes on an already onboarded market, and the market has to be disabled as collateral, then setting totalBorrowCap to 0 would not impact existing borrower who already have utilised the asset as collateral to borrow already.
Setting collateralizationRate to 0 is the only way for the protocol to completely disable the asset(new/existing) as a collateral, however right now the operator is unable to do so.
Proof of Concept
Tools Used
Recommended Mitigation Steps
remove the 0 checks to enable a value of 0 to be set into collateralizationRate.
Lines of code
https://github.com/Tapioca-DAO/tapioca-bar-audit/blob/2286f80f928f41c8bc189d0657d74ba83286c668/contracts/markets/Market.sol#L233-L239
Vulnerability details
Impact
Market in Singularity cannot be disabled using as a collateral (LTV=0) completely by (collateralizationRate to 0) while being borrowable.
a market in lending protocol works by having a collateralFactor (<1) that gives a user deposit value, for borrowing. The deposit while earning interest, also the collateral for borrowing at the same time.
However, there are assets, that is meant to work only as a borrowable asset, but not eligible for collateralization. For example, USDT in Aave (ETH-mainnet). This asset typically has an LTV (collateralFactor) of 0, such that they dont contribute to a user's borrowing ability.
However, in the design of Market.sol, collateralizationRate can only be set through
setMarketConfig
, which has the conditional checks that the new_collateralizationRate
is a non-zero value.This is an issue could right now then the protocol cannot onboard a "USDT-type" asset, this is only borrowable but not intended to work as collateral.
While the operator can set the
totalBorrowCap
to 0 to sunset/stop new borrowing of a newly onboarded market, however consider there is some risk changes on an already onboarded market, and the market has to be disabled as collateral, then settingtotalBorrowCap
to 0 would not impact existing borrower who already have utilised the asset as collateral to borrow already.Setting collateralizationRate to 0 is the only way for the protocol to completely disable the asset(new/existing) as a collateral, however right now the operator is unable to do so.
Proof of Concept
Tools Used
Recommended Mitigation Steps
remove the 0 checks to enable a value of 0 to be set into
collateralizationRate
.Assessed type
Invalid Validation