code-423n4 / 2024-07-benddao-findings

9 stars 6 forks source link

Updating asset collateral params can lead to liquidate borrowers arbitrarily #26

Open c4-bot-3 opened 3 months ago

c4-bot-3 commented 3 months ago

Lines of code

https://github.com/code-423n4/2024-07-benddao/blob/main/src/modules/Configurator.sol#L147-L163

Vulnerability details

Description

One of the key concepts in this protocol is Cross Lending when the contract will calculate the health-factor of the account, If it is unhealthy the liquidator can repay the debt on behalf of the borrower and take their collateral assets at a certain discount price.

The protocol has two main factors to calculate the health-factor for users, The collateralFactor and liquidationThreshold values are unique for each pool and asset. Also, The Pool Admin can update them at any time by triggering Configurator.sol#setAssetCollateralParams()

The responsibility for computing health-factor is GenericLogic.sol#calculateUserAccountData(), which Calculates the user data across the reserves.

However, the current logic uses liquidationThreshold value also to check if the asset will not be used as collateral (but still, users can supply/lend it to be borrowed and earn interest)

File: GenericLogic.sol#calculateUserAccountData()

      if (currentAssetData.liquidationThreshold != 0) {
       /***/
        result.totalCollateralInBaseCurrency += vars.userBalanceInBaseCurrency;
       /***/
      }

The issue is the PoolAdmin can call Configurator.sol#setAssetCollateralParams() at any time to disable accepting an asset as collateral by updating collateralFactor and liquidationThreshold to zero value. So, users suddenly will get liquidated directly by MEV bots.

Impact

Proof of Concept

Foundry PoC:



## Tools Used

Manual Review

## Recommended Mitigation Steps

In case the Pool Admin decides to no longer accept an asset as collateral, Users who are using this asset as collateral should have a period of time to update their loans.
You can use a buffer period or lock time to do this critical update 

## Assessed type

Other
c4-judge commented 3 months ago

MarioPoneder marked the issue as primary issue

MarioPoneder commented 3 months ago

Seems like a valid concern, @thorseldon could you please provide more context concerning you dispute?

MarioPoneder commented 3 months ago

After a second thought, this seems to fall below Centralisation Risk on Contracts which has Owner or Administrator. according to the README.

c4-judge commented 3 months ago

MarioPoneder marked the issue as unsatisfactory: Invalid

MarioPoneder commented 3 months ago

After a third thought, this is exceeding centralization risks, since it's never a good time to change asset collateral params. The params should be cached for ongoing borrows.

c4-judge commented 3 months ago

MarioPoneder marked the issue as satisfactory

c4-judge commented 3 months ago

MarioPoneder marked the issue as selected for report

thorseldon commented 3 months ago

This a parameter configuration which controlled by the DAO governance, any parameters like liquidation threshold should be carefully discussed and reviewed the community and dev team.

We will use timelock to schedule the configuration updating if the proposal voting is passed.

And this finding looks like same with https://github.com/code-423n4/2024-07-benddao-findings/issues/25.

MarioPoneder commented 3 months ago

I understand the centralization concern of this issue is out of scope and changes are carefully reviewed.
However, on a contract level:

For these reasons, Medium severity seems justified.