Borrower can lock lender
funds in market
via WildcatMarket::closeMarket
#101
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-52
edited-by-warden
🤖_12_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/fe746cc0fbedc4447a981a50e6ba4c95f98b9fe1/src/market/WildcatMarket.sol#L226-L287
Vulnerability details
Impact
The
WildcatMarket::closeMarket
is callable only by the market'sborrower
should they decide to end a formerly operatingmarket
. This transfers asset out of market in 2 cases.borrower
ifcurrentlyHeld > totalDebts
.currentlyHeld = totalAssets()
held inmarket
andtotalDebts = state.totalDebts()
withdrawn frommarket
byborrower
.lender
if there is a pending withdrawal batch which is not fully paid off.And what about
lenders
who don't withdraw from the market?There is an edge case here.
Lenders
who deposit into a market but don't request a withdraw can lose funds ifborrower
closes the market.If
lenders
depositloans
into an operationalmarket
, and theborrower
takes nodebt
, and thelenders
do not queue awithdrawalRequest
, theborrower
can intentionally lock thelenders
funds by callingWildcatMarket::closeMarket
.Damage of the protocol's reputation is most likely the goal since the
borrower
has nothing to lose here.Proof of Concept
Below is a test with logs.
The following result was emitted
However, the
borrower
can't remove the tokens from the market since theWildcatMarket::rescueTokens
checks that thetoken
to be rescued is not same as market underlying asset. So the funds will be stuck in the market.Tools Used
Manual review.
Recommended Mitigation Steps
Each
lenders
deposit amount should be stored. When they make a withdrawal, it should be deducted from their total deposits, and if not, their remaining deposit amount should be transferred to them should theborrower
callWildcatMarket::closeMarket
.Assessed type
Other
The text was updated successfully, but these errors were encountered: