# Red Stone Oracle Can Time Travel

Sentiment's RedstoneCoreOracle lets anyone re-submit any valid signed price observation within the 3-minute window, atomically warping prices back and forth to manipulate trades and liquidations.

- Payout: Audit contest
- Severity: high
- Program: Sentiment
- Found by: AlexCzm
- Disclosed: 2024-08-07
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-08-sentiment-v2-judging/issues/23
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-sentiment-v2%3AH-1
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:business-logic vuln:oracle-manipulation

**Target:** RedstoneCoreOracle.updatePrice() price feed cache
**Root cause:** updatePrice() accepts any signed Redstone payload within the 3-minute validity window with no monotonicity or cooldown check, so older observations can overwrite newer ones and be replayed arbitrarily.
**Steps:**
1. Fork Arbitrum at a block where two valid signed Redstone payloads exist within the 3-min window (e.g. ETH:3000 at t, ETH:2989 at t+59s).
2. Call `updatePrice()` with the first payload via `abi.encodePacked(abi.encodeWithSignature("updatePrice()"), beforePayload)`; oracle caches ETH=3000.
3. Call `updatePrice()` with the second payload; oracle caches ETH=2989.
4. Call `updatePrice()` again with the first payload; oracle reverts to ETH=3000, proving arbitrary atomic warping.
5. Repeat within a single tx to trade between minima and maxima or trigger liquidations.
**How found:** Code review of updatePrice() noting it only enforces worst-case 3-min staleness but no monotonicity/cooldown, then hypothesizing that two valid observations in the same window could be replayed alternately; verified with a Foundry PoC using locally signed Redstone payloads.
**Exploitation:** Attacker submits alternating valid signed observations within the 3-minute window in one transaction, buying at the low checkpoint and selling at the high checkpoint (or forcing liquidations at the low price then restoring the high price), extracting value from the protocol's lending/trading logic.
**Escalation:** Chained with lending markets: warp price down to trigger liquidations, then back up to restore collateral value, amplifying profit.
**Insight:** When an oracle caches externally-signed payloads, check whether older-but-still-valid observations can overwrite newer ones; a validity window without monotonic timestamp enforcement enables atomic replay-based price warping.

## Proof of concept (copied exactly from the original report)

**Two signed Redstone payloads with different timestamps**

```
bytes memory beforePayload = (
            generatePayloads
                ? new SherlockMockRedstonePayload().getRedstonePayload("ETH:3000:8,USDC:1:8", "243528007000")
                : bytes(hex"455448000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045d964b80055534443000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005f5e1000038b3667d5800000020000002f3d4b060d793f6ba027fcbb94ab6ba26f17a1527446c42e7bc32e14926aa2f1167d1d38049f766c56d48170b9acdea4315b2132a6e3bba0137b87bf2305df1371c0001000000000002ed57011e0000")
        );

        bytes memory afterPayload = (
            generatePayloads
                ? new SherlockMockRedstonePayload().getRedstonePayload("ETH:2989:8,USDC:1:8", "243528066000" /* 59s in the future */)
                : bytes(hex"45544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004597d40d0055534443000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005f5e1000038b36763d00000002000000290709f13dc06738bbdb82175adbd9b0532cad9db59367b9e63ffac979230fdf222a0043cbcfe6244c30207df1355c416c6165b5d0b1d2a54eab53a807de8a5ed1b0001000000000002ed57011e0000")
        );
```

