Closed c4-bot-10 closed 6 months ago
raymondfam marked the issue as sufficient quality report
raymondfam marked the issue as primary issue
Slippage should be inevitable in this context.
Collateral is set aside for the redeemer at the moment of proposal, it's just not accessible until the wait period is over. Agree that it's not ideal but it is how the system was designed, yes slippage is inevitable for the sake of accurate redemptions (ie. allow space for disputes)
ditto-eth (sponsor) disputed
Agree with the sponsor.
hansfriese marked the issue as unsatisfactory: Invalid
Hi @hansfriese
The report specifically mentions how there can be losses either for the user or for the protocol itself due to fluctuations in ETH
(which are clearly beyond the user's control). As auditors, we need to highlight such errors, and if this error was not specified as a "known error," then I don't see the reason for invalidating it.
I understand your concern but it's an intended behavior of the protocol. So the protocol uses the cached price at the time of submitting a proposal.
Lines of code
https://github.com/code-423n4/2024-03-dittoeth/blob/91faf46078bb6fe8ce9f55bcb717e5d2d302d22e/contracts/facets/RedemptionFacet.sol#L310 https://github.com/code-423n4/2024-03-dittoeth/blob/91faf46078bb6fe8ce9f55bcb717e5d2d302d22e/contracts/facets/RedemptionFacet.sol#L224
Vulnerability details
Impact
When the redeemer submits their candidate
shortRecords
, the collateral is calculated based on theasset price
(LibOracle::getPrice
) and the redemption amount:Additionally, the
timeToDispute
is calculated based on the collateral ratio of the proposals added to theredeemer's slate
, which can extend up to 6 hours. The issue arises during this period when theasset price
changes, resulting in inconsistencies in the collateral received inRedemptionFacet::claimRedemption
orRedemptionFacet::disputeRedemption
. This exposes the redeemer or protocol to potential gains or losses depending on the asset price movement.Proof of Concept
Consider the following scenario:
3000 USD
per1 ETH
.timeToDispute
to elapse. At the current price, the redeemer would receive2 ETH
collateral for redeeming6000 USD
(0.00033 * 6000 USD = 2 ETH
) when the dispute period ends.3500 USD
per1 ETH
.timeToDispute
ends, the redeemer callsRedemptionFacet::claimRedemption
, receiving collateral calculated using the outdated price (2 ETH
). However, since the ETH price increased, the correct collateral should be less (0.00028 * 6000 USD = 1.68 ETH
).2 ETH
with only6000 USD
, which is incorrect because the currentETH price is3500 USD
.The provided test demonstrates that the collateral delivered in
RedemptionFacet::claimRedemption
remains unchanged from the initial calculation inRedemptionFacet::proposeRedemption
, leading to incorrect collateral distribution if the asset price changes during the dispute period.The same can happen when there is an effective dispute because when it occurs, the collateral calculated in
RedemptionFacet::proposeRedemption
is returned. However, this collateral was calculated using anasset
price calculated up to a maximum of 6 hours ago, which most likely means the price is outdated, thus causing the return of collateral in the dispute with a price that may very well be outdated:It can also lead to a lack of incentive for the redeemer since the following scenario can occur:
3000 USD
per1 eth
.shortRecords
proposals and waits until thetimeToDispute
period passes. The redeemer wants to redeem6000 USD
, and at the current price, they would receive2 eth
as collateral (0.00033 *6000 USD
=2 eth
) when the dispute period ends.2500 USD
per1 eth
.timeToDispute
period ends, and the redeemer callsRedemptionFacet::claimRedemption
, resulting in receiving2 eth
as collateral. However, in this case, since the price of the asseteth
decreased, the collateral that should be delivered to the redeemer should be more; it should be (0.0004 *6000 USD
=2.4 eth
).Therefore, there is a lack of incentives for the redeemer to use this system since they are exposed to price fluctuations, and the collateral they receive may not be adequate depending on the movement of the asset's price.
Tools used
Manual review
Recommended Mitigation Steps
The recommendation is to calculate the collateral after the dispute period has elapsed. Additionally, enable the
redeemer
to specify aslippage
tolerance for asset price movements during the dispute period to mitigate the risk of receiving inadequate collateral due to price changes.Assessed type
Context