Daily limit invariant can break when setting limits without daily limit updates #424
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-367
grade-a
insufficient quality report
This report is not of sufficient quality
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_78_group
AI based duplicate group recommendation
Lines of code
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Vault.sol?plain=1#L807-L833
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Vault.sol?plain=1#L1246-L1268
Vulnerability details
Impact
A vault owner has the capability to update the daily limits for both lending and debt increases by invoking the Vault.setLimits() function. Upon calling this function, any changes made to either dailyLendIncreaseLimitMin or dailyDebtIncreaseLimitMin will not apply retroactively for the upcoming cycle. However, if there's no change in the daily limit values, the limits will still be enforced. This behavior can potentially lead to situations where the daily limit increases by up to twice the expected amount, thereby compromising the integrity of the daily limit rule.
Proof of Concept
One of the major usages of setLimits() is to set the lending/debt limits to zero. This acts as a halt on debt/lending operations when an emergency occurs. This feature works as expected. However, a problem occurs if the protocol calls Vault.setLimits() and doesn't update either daily limit value.
I will make the following assumption:
Now let's review both daily limit functions below:
Both functions are nearly identical so let's focus on discussing just _resetDailyDebtIncreaseLimit(). When Vault.setLimits() is called, the admin may or may not update the value of dailyDebtIncreaseLimitMin. Regardless if it's updated or not, Vault.setLimit() forces an update for both daily limits by setting the force argument to true.
By forcing an update when the _dailyDebtIncreaseLimitMin hasn't changed, the daily limit will automatically be reset and users will be able to at most increase the daily limit up to 2x.
Tools Used
Manual inspection.
Recommended Mitigation Steps
The protocol should check if the _dailyDebtIncreaseLimitMin has changed since the last update. If there is a change, then force an update. Otherwise, do nothing.
Assessed type
Other
The text was updated successfully, but these errors were encountered: