Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eeshenggoh - Hardcoded heartbeat duration for RedstoneOracle.sol returns stale price #5

Closed
sherlock-admin4 opened this issue Aug 24, 2024 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. Reward A payout will be made for this issue

Comments

@sherlock-admin4
Copy link
Contributor

sherlock-admin4 commented Aug 24, 2024

eeshenggoh

Medium

Hardcoded heartbeat duration for RedstoneOracle.sol returns stale price

Summary

The protocol uses RedstoneOracle for their prices. The issues lies within hardcoded STALE_PRICE_THRESHOLD which is also the heartbeat for the price feed.

Vulnerability Detail

The protocol mentioned in README.md that it will be deployed on any EVM. Looking at BNB chain, the heartbeat for a popular token BTC is 1 minute. Checkout the Redstone Pricefeed which provides other tokens with heartbeat less than an hour.

    uint256 public constant STALE_PRICE_THRESHOLD = 3600; // 1 hour
    function getValueInEth(address, uint256 amt) external view returns (uint256) {
        //@audit 
        if (priceTimestamp < block.timestamp - STALE_PRICE_THRESHOLD) revert RedstoneCoreOracle_StalePrice(ASSET);

        // scale amt to 18 decimals
        if (ASSET_DECIMALS <= 18) amt = amt * 10 ** (18 - ASSET_DECIMALS);
        else amt = amt / 10 ** (ASSET_DECIMALS - 18);

        // [ROUND] price is rounded down
        return amt.mulDiv(assetUsdPrice, ethUsdPrice);
    }

Impact

Stale prices is returned

Code Snippet

https://github.com/sherlock-audit/2024-08-sentiment-v2/blob/25a0c8aeaddec273c5318540059165696591ecfb/protocol-v2/src/oracle/RedstoneOracle.sol#L64

Tool used

Manual Review

Recommendation

Ensure that STALE_PRICE_THRESHOLD or the heartbeat is not hardcoded.

Duplicate of #126

@github-actions github-actions bot closed this as completed Sep 5, 2024
@github-actions github-actions bot added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. labels Sep 5, 2024
@z3s z3s removed the Medium A Medium severity issue. label Sep 15, 2024
@sherlock-admin4 sherlock-admin4 changed the title Icy Glass Narwhal - Hardcoded heartbeat duration for RedstoneOracle.sol returns stale price eeshenggoh - Hardcoded heartbeat duration for RedstoneOracle.sol returns stale price Sep 15, 2024
@sherlock-admin4 sherlock-admin4 added Non-Reward This issue will not receive a payout and removed Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Sep 15, 2024
@WangSecurity WangSecurity added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. labels Oct 4, 2024
@sherlock-admin2 sherlock-admin2 added Reward A payout will be made for this issue and removed Non-Reward This issue will not receive a payout labels Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

4 participants