The current rate should revert instead of returning a zero value
Summary
Before updating the index, the protocol invokes _rate() to retrieve the current value of the rate, and then records the value of the rate to _latestRate. The issue is that the staticcall can revert due to situations such as:
if (totalActiveOwedM_ <= totalEarningSupply_) {
// NOTE: `totalActiveOwedM_ * minterRate_` can revert due to overflow, so in some distant future, a new
// rate model contract may be needed that handles this differently.
return uint32((uint256(totalActiveOwedM_) * minterRate_) / totalEarningSupply_);
}
// NOTE: `totalActiveOwedM_ * deltaMinterIndex_` can revert due to overflow, so in some distant future, a new
// rate model contract may be needed that handles this differently.
int256 lnArg_ = int256(
_EXP_SCALED_ONE +
((uint256(totalActiveOwedM_) * (deltaMinterIndex_ - _EXP_SCALED_ONE)) / totalEarningSupply_)
);
it is possible for getSafeEarnerRate to revert.
In the second situation, if ttg configures an incorrect rateModel address, the _rate function can revert
Once staticcall revert _rate return a zero value instead of revert this can lead to protocol record a incorrect zero _latestRate.
function currentIndex() public view override(ContinuousIndexing, IContinuousIndexing) returns (uint128) {//@audit-info calculate according to last update timestamp.
// NOTE: Safe to use unchecked here, since `block.timestamp` is always greater than `latestUpdateTimestamp`.
unchecked {
return
// NOTE: Cap the index to `type(uint128).max` to prevent overflow in present value math.
UIntMath.bound128(
ContinuousIndexingMath.multiplyIndicesDown(
latestIndex,
ContinuousIndexingMath.getContinuousIndex(
ContinuousIndexingMath.convertFromBasisPoints(_latestRate),
uint32(block.timestamp - latestUpdateTimestamp)//@audit-info according to last updateTimestamp.
)
)
);
}
}
Additionally, if currentIndex is used to calculate user funds, it may result in an error in the calculation of the user's funds
coffiasd
medium
The current rate should revert instead of returning a zero value
Summary
Before updating the index, the protocol invokes _rate() to retrieve the current value of the rate, and then records the value of the rate to _latestRate. The issue is that the staticcall can revert due to situations such as:
Vulnerability Detail
From
StableEarnerRateModel.sol
we can see: https://github.com/sherlock-audit/2023-10-mzero/blob/main/protocol/src/rateModels/StableEarnerRateModel.sol#L83-L143it is possible for getSafeEarnerRate to revert.
In the second situation, if ttg configures an incorrect rateModel address, the _rate function can revert Once
staticcall
revert_rate
return a zero value instead of revert this can lead to protocol record a incorrect zero_latestRate
.Since we use
_latestRate
to calculatecurrentIndex
https://github.com/sherlock-audit/2023-10-mzero/blob/main/protocol/src/MToken.sol#L158-L173Additionally, if currentIndex is used to calculate user funds, it may result in an error in the calculation of the user's funds
Impact
the calculation of the user's funds is error
Code Snippet
https://github.com/sherlock-audit/2023-10-mzero/blob/main/protocol/src/MToken.sol#L455 https://github.com/sherlock-audit/2023-10-mzero/blob/main/protocol/src/MinterGateway.sol#L986
Tool used
Manual Review
Recommendation
Duplicate of #48