Closed c4-bot-5 closed 3 months ago
hansfriese marked the issue as primary issue
i believe this scenario is unlikely, but if the orderbook is truly inactive then the user can match themselves at oracle price with a small amount to update the time
QA is more appropriate given the unlikely scenario and the available resolution for users. I will invalidate it since there is no QA pool.
hansfriese marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-07-dittoeth/blob/ca3c5bf8e13d0df6a2c1f8a9c66ad95bbad35bce/contracts/tokens/yDUSD.sol#L84 https://github.com/code-423n4/2024-07-dittoeth/blob/ca3c5bf8e13d0df6a2c1f8a9c66ad95bbad35bce/contracts/tokens/yDUSD.sol#L36 https://github.com/code-423n4/2024-07-dittoeth/blob/ca3c5bf8e13d0df6a2c1f8a9c66ad95bbad35bce/contracts/facets/OrdersFacet.sol#L139 https://github.com/code-423n4/2024-07-dittoeth/blob/ca3c5bf8e13d0df6a2c1f8a9c66ad95bbad35bce/contracts/libraries/LibPriceDiscount.sol#L46
Vulnerability details
Impact
The function
yUSD::checkDiscountWindow
is designed to check if the system has had discounted sales. Additionally, theyDUSD::withdraw
function allows users to withdrawdUSD
that have gone through a proposed amount process and are within a 45-day withdrawal period.The issue arises with the call to the function
getInitialDiscountTime()
withinyUSD::checkDiscountWindow
, which will always return more than one second even when an order book becomes inactive.An inactive order book (lacking sell/bid order matches) can create bottlenecks or delays in withdrawals since they only allow withdrawals under specific time frames. The
checkDiscountWindow
function will always revert due togetInitialDiscountTime
not being reset during periods of inactivity in the order book.Proof of Concept
It can be observed that the
getInitialDiscountTime
retrieves the value ofinitialDiscountTime
:This variable is only modified when there is activity in the order book and the
LibPriceDiscount::handlePriceDiscount
function is called inBidOrdersFacet#L338
andLibOrders#L659
:If this function is not called due to inactivity in the
orderBook
,initialDiscountTime
will always be more than a second, causing thecheckDiscountWindow
to revert this results in withdrawals being affected. Consider the scenario where, for example, there is a one-hour discount sales window, and then seven hours pass without any activity in theorderBook
. However,initialDiscountTime
will have a value greater than one second because there were penalties applied seven hours ago. Currently, these penalties are no longer being applied, so thewithdrawal
should be available, especially since the function itself has a period during which a withdrawal can be made; otherwise, the process must be restarted.The following test demonstrates how the user is unable to make a withdrawal because the order book is inactive. Even after the time to make a withdrawal has passed, the user would need to call
proposeWithdraw
again to restart the process, however, this is not possible (step 5 revert) as the order book remains inactive.:Tools used
Manual review
Recommended Mitigation Steps
It is recommended to implement a rule that allows for a window of inactivity in the order book, enabling withdrawals during this period.
Assessed type
Invalid Validation