Skip to content
Business logic Audit finding Intermediate

Protocol should update interest rate after changing rate model in the configurator module

After the pool admin changes the interest rate model, the protocol does not immediately update the interest rate, so interest continues to be calculated using the old model's rates until the next update. An attacker could potentially exploit this to pay or receive incorrect interest amounts for a short period.

SpicyMeatball Follow

Originally disclosed on Code4rena

Submitted by SpicyMeatball

https://github.com/code-423n4/2024-07-benddao/blob/main/src/libraries/logic/ConfigureLogic.sol#L526 https://github.com/code-423n4/2024-07-benddao/blob/main/src/libraries/logic/ConfigureLogic.sol#L626

Impact

After updating the interest model, the protocol does not update the interest rate, resulting in interest being calculated at the old model rates for some time.

Proof of Concept

The pool admin can change rate model in the Configurator.sol module:

  function executeSetAssetLendingRate(
    address msgSender,
    uint32 poolId,
    address asset,
    uint8 groupId,
    address rateModel_
  ) internal {
    DataTypes.PoolStorage storage ps = StorageSlot.getPoolStorage();

    require(groupId >= Constants.GROUP_ID_LEND_MIN, Errors.INVALID_GROUP_ID);
    require(groupId <= Constants.GROUP_ID_LEND_MAX, Errors.INVALID_GROUP_ID);
    require(rateModel_ != address(0), Errors.INVALID_ADDRESS);

    DataTypes.PoolData storage poolData = ps.poolLookup[poolId];
    _validateCallerAndPool(msgSender, ps, poolData);

    DataTypes.AssetData storage assetData = poolData.assetLookup[asset];
    require(assetData.underlyingAsset != address(0), Errors.ASSET_NOT_EXISTS);
    require(assetData.assetType == Constants.ASSET_TYPE_ERC20, Errors.ASSET_TYPE_NOT_ERC20);

    require(assetData.groupList.contains(groupId), Errors.GROUP_NOT_EXISTS);

    DataTypes.GroupData storage groupData = assetData.groupLookup[groupId];
>>  groupData.rateModel = rateModel_;

    emit Events.SetAssetLendingRate(poolId, asset, groupId, rateModel_);
  }

However, interest rate is not updated, meaning interest will be calculated with the cached old model rates until InterestLogic.updateInterestRates is finally called.

Recommended Mitigation Steps

    ---SNIP---

    DataTypes.GroupData storage groupData = assetData.groupLookup[groupId];
    groupData.rateModel = rateModel_;
+   InterestLogic.updateInterestRates(poolData, assetData, 0, 0)

    emit Events.SetAssetLendingRate(poolId, asset, groupId, rateModel_);
  }

thorseldon (BendDAO) confirmed and commented:

Fixed here.

We suggest adjust the severity level to Low Risk or Information, because there’s many TX action will frequently trigger to update the interest index, e.g., borrow/repay. We check the same logic exist in Aave V2 & V3.

0xTheC0der (judge) commented:

Thanks for adding that clarification!

Similar case as in Issue #7. The same reasoning applies here.


The original report as published on Code4rena, by SpicyMeatball. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The function that updates the rate model does not call the function that recalculates and stores the current interest rate.

What the attacker needed

Pool admin privileges

The fix

The function should call the interest rate update logic immediately after setting the new rate model.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In a lending protocol, the interest rate is set by a model that the admin can change. When the admin changes the model, the protocol should immediately recalculate the interest rate. Here, it doesn't, so for a short time interest is still calculated using the old model's rates, which could be unfair to users.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by SpicyMeatball

View all

18 more disclosed reports, best first.

More from BendDAO Invitational

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.