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

bin2chen - rolloverQueue may lead to GAS OUT risk #218

Closed
sherlock-admin opened this issue Mar 27, 2023 · 0 comments
Closed

bin2chen - rolloverQueue may lead to GAS OUT risk #218

sherlock-admin opened this issue Mar 27, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label 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

bin2chen

medium

rolloverQueue may lead to GAS OUT risk

Summary

rolloverQueue may be too long, leading to GAS OUT

Vulnerability Detail

Users can add rolloverQueue by enlistInRollover
and mintRollovers() does not remove the rolloverQueue.
Only the user can delistInRollover to shorten the array, if the user is on the lose side, it is very likely that he will not perform delistInRollover.
So rolloverQueue is likely to get bigger and bigger
But this array copy is used in these places in the contract or loop array

    function mintRollovers(uint256 _epochId, uint256 _operations)
        external
        epochIdExists(_epochId)
        epochHasNotStarted(_epochId)
        nonReentrant
    {
...
        QueueItem[] memory queue = rolloverQueue;
    function getRolloverTVL(uint256 _epochId)
        public
        view
        returns (uint256 tvl)
    {
        for (uint256 i = 0; i < rolloverQueue.length; i++) {
            if (
                rolloverQueue[i].epochId == _epochId &&
                (previewWithdraw(
                    rolloverQueue[i].epochId,
                    rolloverQueue[i].assets
                ) > rolloverQueue[i].assets)
            ) {
                tvl += rolloverQueue[i].assets;
            }
        }
    }

these places can cause GAS OUT, or a lot of wasted GAS
Need to add a method to Remove Invalid queue items from rolloverQueue

Impact

mintRollovers and getRolloverTVL maybe GAS OUT

Code Snippet

https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/Carousel.sol#L387

Tool used

Manual Review

Recommendation

add a method to Remove Invalid queue items from rolloverQueue

Duplicate of #172

@github-actions github-actions bot closed this as completed Apr 3, 2023
@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Apr 3, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Apr 11, 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 Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant