Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.

stopthecap - Sequencer is incorrectly validated without checking for the GRACE_PERIOD #11

Closed
sherlock-admin opened this issue Jul 5, 2023 · 0 comments
Labels
Non-Reward This issue will not receive a payout

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Jul 5, 2023

stopthecap

medium

Sequencer is incorrectly validated without checking for the GRACE_PERIOD

Summary

Sequencer is incorrectly validated without checking for the GRACE_PERIOD

Vulnerability Detail

According to Chainlink docs about the sequencer in Arbitrum: https://docs.chain.link/data-feeds/l2-sequencer-feeds :

When the sequencer comes back up after an outage, wait for the GRACE_PERIOD_TIME to pass before accepting answers from the data feed. Subtract startedAt from block.timestamp and revert the request if the result is less than the GRACE_PERIOD_TIME.
If the sequencer is up and the GRACE_PERIOD_TIME has passed, the function retrieves the latest answer from the data feed using the dataFeed object.

As you can see in unstoppable code, it is checked that the sequencer is up:
https://github.com/sherlock-audit/2023-06-unstoppable/blob/94a68e49971bc6942c75da76720f7170d46c0150/unstoppable-dex-audit/contracts/margin-dex/Vault.vy#L588-L592

but it is not checked that the GRACE_PERIOD_TIME has passed, which will cause unstoppable to get incorrect/stale prices while the GRACE_PERIOD_TIME has not yet been over

Impact

GRACE_PERIOD_TIME has not yet been over will cause unstoppable to get stale prices.

Code Snippet

https://github.com/sherlock-audit/2023-06-unstoppable/blob/94a68e49971bc6942c75da76720f7170d46c0150/unstoppable-dex-audit/contracts/margin-dex/Vault.vy#L588-L592

Tool used

Manual Review

Recommendation

This is how it would look to check the grace period in solidity:

uint256 private constant GRACE_PERIOD_TIME = 3600;
 error GracePeriodNotOver();

function isSequencerActive() internal view returns (bool) {
    (, int256 answer, uint256 startedAt,,) = sequencer.latestRoundData();
    if (block.timestamp - startedAt <= GRACE_PERIOD_TIME || answer == 1)
        return false;
    return true;
}

Duplicate of #124

@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 Jul 10, 2023
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Jul 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

1 participant