oracle_lib treats a price as stale only after a fixed TIMEOUT of 72 hours (259200 seconds), used in the single staleness assertion.
This constant is hardcoded and cannot be adjusted per feed or per market conditions, so it cannot adapt to the actual heartbeat/update frequency of the price feeds the protocol relies on.
Likelihood:
The TIMEOUT applies to every price read on every mint, redeem, and liquidation, so the fixed window governs all oracle-dependent operations at all times.
It is a compile-time constant with no setter, so it cannot track changing market conditions or differing feed heartbeats.
Impact:
72 hours is far longer than a typical ETH/BTC feed heartbeat, so the protocol can accept and act on prices that are up to three days stale, mispricing mints and liquidations during volatile periods.
Because the window cannot be tuned per feed or per market, it is simultaneously too loose for fast-moving assets and impossible to tighten without a redeploy, leaving the staleness check misaligned with real update frequency.
The test records a fresh price, advances 71 hours (well beyond any ETH/BTC heartbeat but under the 72h TIMEOUT), and shows the oracle still returns the stale price without reverting:
Run: mox test --match test_poc_fixed_timeout_accepts_stale -vvv
Observed: a price 71 hours old is returned without reverting; only past the fixed 72h does it revert. The hardcoded constant cannot be tuned to a feed's real heartbeat.
Replace the single hardcoded TIMEOUT with a configurable, per-feed staleness window sized to each feed's heartbeat (e.g. ~1 hour for ETH/BTC), set at deployment and adjustable by governance:
## Description In this contract, the TIMEOUT is set as a fixed constant (72 hours, or 259200 seconds). This means that if the oracle price data is not updated within 72 hours, the data will be considered outdated, and the contract will trigger a revert. ## Vulnerability Details At this location in the code, <https://github.com/Cyfrin/2024-12-algo-ssstablecoinsss/blob/4cc3197b13f1db728fd6509cc1dcbfd7a2360179/src/oracle_lib.vy#L15> ```Solidity TIMEOUT: constant(uint256) = 72 * 3600 ``` the timeout is directly set to 72 hours. For an oracle, which cannot dynamically adjust the price updates, this is a suboptimal approach. ## Impact - Fixed Timeout: The TIMEOUT is hardcoded to 72 hours. In markets with frequent fluctuations or assets that require more frequent price updates, 72 hours might be too long. Conversely, if the timeout is too short, it could cause frequent errors due to the inability to update data in time, disrupting normal contract operations. - Non-adjustable Timeout: If the contract's requirements change (e.g., market conditions evolve or the protocol requires more flexibility), the fixed TIMEOUT cannot be dynamically adjusted, leading to potential mismatches with current needs. - Lack of Flexibility: The current timeout mechanism is static and cannot be adjusted based on market volatility or the frequency of oracle updates. In volatile markets, a shorter TIMEOUT might be necessary, while in stable markets, a longer timeout would be more appropriate. \##Tools Used Manual review ## Recommendations Introduce a dynamic price expiration mechanism that adjusts based on market conditions. Use volatility data (such as standard deviation or market price fluctuation) to dynamically adjust the timeout period. This can be achieved by monitoring market volatility and adjusting the TIMEOUT accordingly: ```Solidity # Monitor market volatility and dynamically adjust TIMEOUT @external def adjustTimeoutBasedOnVolatility(volatility: uint256): if volatility > HIGH_VOLATILITY_THRESHOLD: self.TIMEOUT = SHORTER_TIMEOUT # In high volatility, decrease TIMEOUT else: self.TIMEOUT = LONGER_TIMEOUT # In stable market, increase TIMEOUT log TimeoutAdjusted(self.TIMEOUT) ```
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.