repayDeliquentDebt
is not effective, as the market will become delinquent again on next block
#73
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-62
partial-50
Incomplete articulation of vulnerability; eligible for partial credit only (50%)
🤖_71_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/market/WildcatMarket.sol#L172-L172
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/market/WildcatMarketBase.sol#L541-L542
Vulnerability details
Summary
repayDelinquentDebt
allow a borrower to repay the exact amount necessary to cover the delinquency, i.e make thetotalAssets
in the market equal to theliquidityRequired
.But as fees accrues every seconds (and new block), the market will be delinquent again on next block.
Vulnerability details
The
repayDelinquentDebt
works that way:_getUpdatedState()
. During this call, as the market is delinquent, delinquency is applied (either by applying fees or increasing the delinquent timer)delinquentDebt
delinquentDebt
is made from the borrower to the market)state.isDelinquent
variable is set to false in_writeState
asstate.liquidityRequired() == totalAssets()
now.The issue here, is that on the next block that will occur, any stateful interaction (starts with
_getUpdatedState()
and ends with_writeState
) with the market will increase the fees and reserve ratio in_getUpdatedState()
, increasingstate.liquidityRequired()
, making the market delinquent again when_writeState
is called at the end.Impact
This will cause the market to still accrue delinquency fees, causing a loss for the borrower.
The
repayDelinquentDebt
purpose is defeated by the fact this only remove the delinquency of the market for one block, which is not effective to help a borrower solve the issue effectively, who will see the delinquency continue to affect its market, causing additional cost that could have been avoided by adding a buffer of repayment.Proof of Concept
Add this test to
test/market/WildcatMarket.t.sol
:Ouput for the test:
Tools Used
Manual review
Recommended Mitigation Steps
The goal is to give more time such that the
timeDelinquent
timer can decrease when the delinquency is repaid, and allow the borrower to act.I see 2 solutions:
This would also cover the 1-2 wei corner case of stETH (a rebasing token) in case a market uses it as its asset.
Assessed type
Math
The text was updated successfully, but these errors were encountered: