Open code423n4 opened 1 year ago
tbrent marked the issue as sponsor disputed
It is preferred to minimize RSR selling and to sell off excess SOUND collateral before RSR in order to prevent double trading. If we were to change the order in the way described, then in the event of a default there would be large RSR selling, possibly followed by a similar amount of SOUND collateral selling for RSR, which would then be treated as reward RSR and dripped out to stakers. This is less good than simply using the SOUND collateral in the first place, even though technically this uses revenue that could be destined for either RToken holders or RSR stakers.
0xean marked the issue as unsatisfactory: Invalid
I think there is a misunderstand about he scenario I presented. I agree that "sell off excess SOUND collateral before RSR in order to prevent double trading". But the "excess SOUND collateral" should be the part of collateral hold by BackingManager - rToken.basketsNeeded amount
. The current code leads to early selling the collateral which is equal to rToken.basketsNeeded when the rToken is undercollateralized.
Although the effect on the final state is little, this causes users who would have the opportunity to partially redeem their collateral at the rsr auction stage to lose a portion of their principal.
The RSR stakeAmount in the poc test is 10, the sale sequence is:
defaulted coll token 0 -> SOUND coll token1 -> rsr
The token1 is sold before rsr, even though the baskets needs 50 token1 and there is not any excess SOUND collateral.
But if RSR stakeAmount is changed to 25, the sale sequence will be normal:
defaulted coll token 0 -> rsr -> rToken is fullyCollateralized
cc @tbrent
Hmm this is a good and subtle point. It took me a while to see the argument behind it. In short, if the protocol expects to end up undercollateralized in the best-case, then selling RSR first has no downside and maximizes RToken redeemCustom()
value. The only case where this has a downside is when the clearing price of the RSR auction ends up being better than the best-case price (out-of-band outcome), which can cause double-trading of the value gotten from the unexpected gain.
I don't think this should be considered Medium though since it does not impact the ultimate redemption value of the RToken, only the mid-rebalancing value. It is not actually a stated property of the protocol that RToken redemption value during rebalancing must be greedily maximized. It is important that the RToken redemption value during rebalancing be up-only in order to disincentivize bank runs, but I think we have that property regardless of which order of sale is used. If this is not the case please correct me and then I would be happy to accept this as Medium.
Not sure whether we will mitigate yet, so just acknowledging for now.
tbrent marked the issue as sponsor acknowledged
tbrent marked the issue as disagree with severity
@5z1punch care to comment on
It is important that the RToken redemption value during rebalancing be up-only in order to disincentivize bank runs, but I think we have that property regardless of which order of sale is used. If this is not the case please correct me and then I would be happy to accept this as Medium.
before I make a final call here?
@0xean Alright, Im sure that now there is not any misunderstand about the issue. And as the comment It is not actually a stated property of the protocol that RToken redemption value during rebalancing must be greedily maximized
, I agree that it should be a QA.
Just a reminder, the tag unsatisfactory
and Med
should be removed
0xean changed the severity to QA (Quality Assurance)
Lines of code
https://github.com/reserve-protocol/protocol/blob/c4ec2473bbcb4831d62af55d275368e73e16b984/contracts/p1/mixins/RecollateralizationLib.sol#L311-L413 https://github.com/reserve-protocol/protocol/blob/c4ec2473bbcb4831d62af55d275368e73e16b984/contracts/p1/mixins/RecollateralizationLib.sol#L151-L269
Vulnerability details
According to the risk evaluation from the official app:
The staked RSR will be the first funds to be sold when RToken default. As recollateralization and Sharing most of the profits, the RSR staker should be slashed preferentially before RToken holders.
When coll has defaulted, the correct sale sequence should be:
But because of
RecollateralizationLibP1.nextTradePair
leaves the rsr calculation at the end of the function, when stake rsr amount can't increase therange.top
to thebasketsNeeded
, the SOUND colls will be sold after the defaulted colls. And the rsr will be sold last.Impact
Break the promise about rsr overcollateralization, which means the rtoken holders suffer from more risk of default than they should have but dont get more revenues.
Proof of Concept
POC git patch test/Recollateralization.test.ts
RUN test:
log:
Tools Used
Manual review
Recommended Mitigation Steps
Separate branching for SOUND collateral in the
RecollateralizationLibP1.nextTradePair
Assessed type
Context