Closed sherlock-admin closed 1 year ago
This may or may not be valid. It's not clear to me that it's even possible to get totalfCash in a market equal to zero. I think it may not actually be possible in practice.
Even if it is possible, this is a low severity issue because getting a market into this state requires capital because you have to lend, and it also costs money in the way of the transaction fee you pay upon lending. And there is no upside to the attacker other than wasting our time.
iglyx
medium
Zero utilization of any market blocks upgrade
Summary
The case of zero utilization isn't treated in the MigratePrimeCash's _calculateInterestRateCurves() logic, so it looks like the upgrade will fail if any market has zero utilization.
Vulnerability Detail
When for any
currencyId
for any market in the dictionary it ismarket.totalfCash == 0
, the MigratePrimeCash's_patchFix() -> _setfCashInterestRateCurves(currencyId, settings.fCashCurves) -> _calculateInterestRateCurves(...)
call reverts and migration fails.In the same time zero utilization is a normal state of a market and treating it can be straightforward.
Impact
Migration fails whenever there is a market with zero
totalfCash
, which might be orchestrated by an attacker to implement a griefing attack.Since any zero cash market fails the whole _patchFix() call, which involves substantial amount of operations and will be carried out on the mainnet, the impact/cost profile of such attack can look attractive enough.
Code Snippet
Zero
utilization
returned by InterestRateCurve.getfCashUtilization will cause _calculateInterestRateCurves() revert:https://github.com/sherlock-audit/2023-03-notional/blob/main/contracts-v2/contracts/external/patchfix/MigratePrimeCash.sol#L304-L318
getfCashUtilization() is zero when
totalfCash == 0
:https://github.com/sherlock-audit/2023-03-notional/blob/main/contracts-v2/contracts/internal/markets/InterestRateCurve.sol#L230-L242
As an example, zero utilization can be the live case and it is handled within InterestRateCurve (and other parts of rate logic):
https://github.com/sherlock-audit/2023-03-notional/blob/main/contracts-v2/contracts/internal/markets/InterestRateCurve.sol#L354-L402
Tool used
Manual Review
Recommendation
Consider treating it as a special case, for example:
https://github.com/sherlock-audit/2023-03-notional/blob/main/contracts-v2/contracts/external/patchfix/MigratePrimeCash.sol#L313-L318