in BackingManagerP1::rebalance
Wrong assertion will lead to panic reverts
#158
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
🤖_03_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/p1/mixins/RecollateralizationLib.sol#L75
Vulnerability details
Impact
compromiseBasketsNeeded
would never be called), and the RToken state would stay undercollateralizedProof of Concept
The problem arises in
BackingManagerP1::rebalance
in Line 153 we call
prepareRecollateralizationTrade
and returnbool doTrade
seeing the implementation of itin Line 47 we call
nextTradePair
but the problem is that we assume that it always returns a valid pair with enough Amounts, which is notisEnoughToSell
check functionThe
doTrade
bool returned by eitherprepareTradeSell
orprepareTradeToCoverDeficit
is basically if the amounts are dust or not.doTrade
so we need it to always to be true, this has two problemsIn
rebalance
we check in Line 155 if
doTrade
is true (ir. not dust) we initiate a TradeElse in Line 168 we call
compromiseBasketsNeeded
but in fact due to the assert in
prepareRecollateralizationTrade
we either do trade or revert the txnThe above facts combined RToken maybe
reweightable
== false and RSR stakes can never be withdrawn in uncollateralized sate, due to this check inwithdraw
:Combined with the fact that RTokens holers can yet
redeemCustom
their tokens, leading to less collateral held in the backingManager which will causeisEnoughToSell
to return false.Then this will leave the protocol in very bad state and RSR stakers to be in a bad situation
For example:
rebalance
will fail due to the above descriptionweightable
by setting new basket fitting the current stateTools Used
manual review
Recommended Mitigation Steps
remove the redundant assert in the library that causes the problem and overhead.
Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: