The reserveRatioBips
will be incorrect if a market APR is reduced again two weeks after the initial reduction of over 25%
#46
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
edited-by-warden
grade-a
primary issue
Highest quality submission among a set of duplicates
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_12_group
AI based duplicate group recommendation
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/access/MarketConstraintHooks.sol#L204-L288
Vulnerability details
Impact
The
reserveRatioBips
will be incorrect if a market APR is reduced again two weeks after the initial reduction of over 25%. The borrower of the market has to repay more assets to ensure the market is not delinquent.Proof of Concept
The Wildcat protocol specifies that a borrower can reduce the APR of their market as follows:
A borrower can reduce the market APR by up to 25% first, and two weeks later, the borrower can reduce it no more than 25% again with no penalty.
However, it a borrower reduces the market APR by more than 25% first, the borrower can not reduce it no more than 25% with no penalty after two weeks.
Copy below codes to WildcatMarket.t.sol and
run forge test --match-test test_setAnnualInterestAndReserveRatioBips_RestoreReserveRatioFail
:As we can see, the first APR reduction(10% -> 7%) is expired, and the second APR reduction (7% -> 6%) is no more than 25%. The
reserveRatioBips
should be restored to 20%, however it is wrongly set to 80%.Tools Used
Manual review
Recommended Mitigation Steps
When a market APR has been reduced more than 25% first
reserveRatioBips
should be reset to the original reserve ratioreserveRatioBips
should be updated to twice the new APR reduction rate (accounted from the previous reduced APR)To illustrate:
Initial
annualInterestBips
is 10%,reserveRatioBips
is 20%.annualInterestBips
is reduced to 7%, nowreserveRatioBips
is 60%annualInterestBips
can be reduced to 6% andreserveRatioBips
is restored to 20%(annualInterestBips
can be reduced to 4.2% andreserveRatioBips
is set to 80% (However, it seems impossible to fix this issue in the current logic by slight improvement.
Since Reducing APR logic works for all market and it is not tied to any specific hook, It is recommended to move all codes in MarketConstraintHooks#onSetAnnualInterestAndReserveRatioBips() to WildcatMarketConfig.sol, and modify codes to mitigate this issue based on above suggestions.
Assessed type
Context
The text was updated successfully, but these errors were encountered: