Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

yixxas - It is still possible for users to lose their funds when the counterparty vault has no deposits #153

Closed
sherlock-admin opened this issue Mar 27, 2023 · 4 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Escalation Resolved This issue's escalations have been approved/rejected Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Mar 27, 2023

yixxas

medium

It is still possible for users to lose their funds when the counterparty vault has no deposits

Summary

triggerNullEpoch() is implemented to protect against the case of when one side of the vault has no deposits. However, it is still possible for users to lose funds if triggerNullEpoch() is not called before the end of the epoch, as triggerEndEpoch() can now be called.

Vulnerability Detail

triggerNullEpoch() can be called by anyone once epoch has started and doing so will allow users to withdraw their assets from the vault if counterparty vault is empty. However, in the case where this is not called, for various reasons such as a downtime on arbitrum or simply having no one calling the function, users can lose their deposits.

The issue here is that triggerEndEpoch() can be called as long as block.timestamp > uint256(epochEnd). This will lead to the same issue as found in H-04 in the previous Y2k audit done at C4. code-423n4/2022-09-y2k-finance-findings#312

triggerEndEpoch() can be called regardless of whether it is possible to trigger null epoch. We should enforce the impossibility of it onchain and not rely or assume that triggerNullEpoch() will always be triggered before epoch ends.

Impact

Users can lose deposits when counterparty vault has 0 deposits.

Code Snippet

https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Controllers/ControllerPeggedAssetV2.sol#L160

Tool used

Manual Review

Recommendation

Add an additional check to triggerEndEpoch() to disallow calling of it should one side of the risk/hedge vault have 0 deposits and prevent it from being callable even if block.timestamp > uint256(epochEnd).

Duplicate of #108

@github-actions github-actions bot closed this as completed Apr 3, 2023
@github-actions github-actions bot added the Excluded Excluded by the judge without consulting the protocol or the senior label Apr 3, 2023
@sherlock-admin sherlock-admin added the Non-Reward This issue will not receive a payout label Apr 11, 2023
@yixxas
Copy link

yixxas commented Apr 11, 2023

Escalate for 10 USDC

Dupe of #108

@sherlock-admin
Copy link
Contributor Author

Escalate for 10 USDC

Dupe of #108

You've created a valid escalation for 10 USDC!

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.

@sherlock-admin sherlock-admin added the Escalated This issue contains a pending escalation label Apr 11, 2023
@hrishibhat
Copy link

Escalation accepted

Valid duplicate of #108

@sherlock-admin
Copy link
Contributor Author

Escalation accepted

Valid duplicate of #108

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

@sherlock-admin sherlock-admin added Escalation Resolved This issue's escalations have been approved/rejected and removed Escalated This issue contains a pending escalation labels Apr 24, 2023
@hrishibhat hrishibhat added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label and removed Excluded Excluded by the judge without consulting the protocol or the senior labels Apr 24, 2023
@sherlock-admin sherlock-admin added Medium A valid Medium severity issue Reward A payout will be made for this issue and removed Non-Reward This issue will not receive a payout labels Apr 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Escalation Resolved This issue's escalations have been approved/rejected Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

3 participants