-
Notifications
You must be signed in to change notification settings - Fork 6
giraffe - Users receive less than expected due to lack of slippage and deadline controls for requestWithdraw #66
Comments
1 comment(s) were left on this issue during the judging contest. takarez commented:
|
Escalate. Disagree that it is a duplicate of #35 based on my recommendations for a slippage parameter and deadline. My recommendation would fix #35 but it does more than fix that unique scenario. For the same reasons that slippage and deadline are necessary in swaps (common medium finding), a user should expect to get back an amount + within a timeline that is reasonable. The current design could see a user getting back exceptionally less and wait indefinitely for the withdrawal to complete. |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
@giraffe0x This issue has the exact same root cause as #35. Just because you introduce a deadline check doesn't mean it suffice a separation, even more so when recently, deadline checks has been deemed as not sufficient to be deemed as medium severity anymore in sherlock, given it is users responsibility to set high enough gas to execute the request and slippage alone would be sufficient to resolve this issue. Additionally, to my knowledge, the loss is only on paper, given JUSD can always be retained with the same value as the collateral initially deposited, but during the time of transaction, if index price changes, that is another topic up for debate Examples: sherlock-audit/2023-06-tokemak-judging#886 |
Planning to reject escalation and keep issue state as is, because root cause in both reports is the same. |
Escalations have been resolved successfully! Escalation status:
|
giraffe
medium
Users receive less than expected due to lack of slippage and deadline controls for requestWithdraw
Summary
In FundingRateArbitrage, withdrawal is done in two steps: user submits
requestWithdraw()
and wait for owner topermitWithdrawRequests()
. Due to the time lag between the two steps, a user may receive much less USDC than expected, and is also unable to cancel his request (could wait for an arbitrary amount of time for withdrawal to complete).Vulnerability Detail
Based on code comments, there could be a time lag of 24 hours between a request and permitted withdrawal. There are several issues at hand:
User gets back less USDC than expected.
getIndex()
returns an index which is the ratio between the net value of the system and the total balance of USDC earned by liquidity providers. This index helps determine the amount of USDC that corresponds to the user's JUSD balance at the current state of the system. If index changes drastically between request and permit, the user could get back a lot less USDC than expected. Due to reasons mentioned below, this time lag could extend beyond 24 hours allowing the index to change further due to market conditions.User's request cannot be fulfilled and is stuck. If index changes significantly, there is a chance that amount < fees and the permit will revert. In another scenario, if a user is blacklisted from USDC, the transfer of USDC will fail and the permit will revert. At this point, user would have transferred JUSD out but is unable to receive USDC back until the request is permitted.
Impact
User may get back less USDC than expected and/or could wait indefinitely for the request to be permitted, with no avenue to rescind the request.
Code Snippet
https://github.com/sherlock-audit/2023-12-jojo-exchange-update/blob/main/smart-contract-EVM/src/FundingRateArbitrage.sol#L282
https://github.com/sherlock-audit/2023-12-jojo-exchange-update/blob/main/smart-contract-EVM/src/FundingRateArbitrage.sol#L304
Tool used
Manual Review
Recommendation
Duplicate of #35
The text was updated successfully, but these errors were encountered: