Risk of mass liquidation after pool/asset pause and unpause, due to borrow interest compounding implementation
The borrow interest index continues to compound while a pool or asset is paused, even though users cannot repay during that time. When unpaused, many accounts could be immediately liquidated because their debt has grown without any chance to repay.
Submitted by oakcobalt
Current pausing features allow a pool to be globally paused (all assets borrow, repay, liquidation pausing) and asset pausing (specific asset borrow, repay, liquidation pausing). See validatePoolBasic() and validateAssetBasic() which are checked in borrow, repay, and will revert if the pool or the asset is paused.
The problem is the borrow interest compounding implementation (InterestLogic::_updateBorrowIndex) will not factor in the duration of pausing when a user cannot repay a loan.
//src/libraries/logic/InterestLogic.sol
function _updateBorrowIndex(DataTypes.AssetData storage assetData, DataTypes.GroupData storage groupData) internal {
// borrow index only gets updated if there is any variable debt.
// groupData.borrowRate != 0 is not a correct validation,
// because a positive base variable rate can be stored on
// groupData.borrowRate, but the index should not increase
if ((groupData.totalScaledCrossBorrow != 0) || (groupData.totalScaledIsolateBorrow != 0)) {
//@audit Case: asset paused and unpaused, assetData.lastUpdateTimestamp will be a timestamp before paused, interests compound during pausing
|> uint256 cumulatedBorrowInterest = MathUtils.calculateCompoundedInterest(
groupData.borrowRate,
assetData.lastUpdateTimestamp
);
uint256 nextBorrowIndex = cumulatedBorrowInterest.rayMul(groupData.borrowIndex);
groupData.borrowIndex = nextBorrowIndex.toUint128();
}
}
Interests continuously compound with no repayment allowed. When unpaused, many accounts are vulnerable to immediate liquidation out of users’ control.
Recommended Mitigation Steps
Consider storing pause/unpause timestamp to allow skipping borrow interests compounding for the duration of the pause.
thorseldon (BendDAO) acknowledged and commented:
It’s our service design. Pause & unpause should be only used for emergency case, the accrued interest should be very small.
We suggest adjust the severity level to Informative.
Although pause durations are intended to be small, they can be arbitrarily long and put users at risk on unpausing due to compounding in the meantime. This could be mitigated on contract level; therefore, leaning towards maintaining Medium severity.
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
Likely the borrow interest index is updated using the last update timestamp without accounting for the pause duration, so interest compounds during the pause.
Impact
Users could be liquidated immediately after unpausing because their debt has grown during the pause, although the protocol team says pauses are meant to be short and the accrued interest should be small.
What the attacker needed
Pool or asset is paused; users cannot repay during pause; pause lasts long enough for interest to grow
The fix
The borrow interest calculation should skip compounding for the duration of the pause, for example by storing pause and unpause timestamps.
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 system, interest on a loan keeps growing over time. If the system is paused for an emergency, users cannot repay their loans, but the interest still grows as if nothing happened. When the pause is lifted, some users may suddenly owe more than their collateral is worth and get liquidated (their collateral is sold off) without having had a chance to act.
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.