Submitted by ether_sky, also found by Bauchibred
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/p1/StRSR.sol#L279
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/p1/StRSR.sol#L658
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/p1/StRSR.sol#L368
When stakers want to unstake their StRSR, they cannot withdraw RSR immediately.
Instead, each withdrawal enters a queue and will become available after the unstaking delay period.
This queue operates on a FIFO basis, meaning earlier withdrawals are processed before later ones.
Stakers can also cancel their withdrawals, and the RSR will be restaked immediately.
However, even canceled withdrawals can still impact future withdrawal requests.
Suppose the current unstakingDelay is set to 1 day, and a user decides to unstake some amount of StRSR at time T (line 279).
This request enters a queue, which we assume is empty at this point, making the withdrawal available at T + 1 day (line 658).
Now, lets assume the user cancels this withdrawal at time T for testing purposes. Instead of removing the withdrawal from the queue, we simply increase the first available ID, which is a good approach and is easy to implement (line 368).
Even though the queue technically still contains one item (the canceled withdrawal request), we can consider the queue empty in terms of available withdrawals.
Later, the owner updates the unstakingDelay to 1 hour.
The user attempts to unstake again, expecting to withdraw just 1 hour later, which should be possible.
However, the canceled withdrawal still impacts this new request.
In line 654, the index is 1 , and in line 657, lastAvailableAt is set to T + 1 day due to the canceled withdrawal.
As a result, in line 658, the availableAt for the new withdrawal is calculated as T + 1 hour, but since this is less than T + 1 day, the new withdrawal is also pushed to be available 1 day later.
This situation is clearly unfair to the user.
The availableAt of canceled withdrawals should not be considered when determining the availability of new withdrawals.
Please add below test to the test/ZZStRSR.test.ts
akshatmittal (Reserve) commented:
cccz (judge) decreased severity to Low and commented:
ether_sky (warden) commented:
cccz (judge) increased severity to Medium and commented:
Reserve mitigated
Status: Mitigation confirmed. Full details in reports from Bauchibred, ether_sky and RadiantLabs.
