Algo Ssstablecoinsss

AI First Flight #2
Beginner FriendlyDeFi
EXP
View results
Submission Details
Severity: medium
Valid

72-hour oracle stale-price timeout allows minting against 3-day-old prices

Root + Impact

Description

  • Normal behavior: price reads through the oracle library should reject stale Chainlink answers so that all mint, redeem, and liquidation math uses current collateral prices.

  • The issue: oracle_lib.vy defines a stale-price timeout of 72 hours, so the protocol keeps operating on up to 3-day-old prices. During a sharp collateral crash combined with an oracle outage (or a paused/stale feed), collateral stays overvalued and users can call deposit_collateral_and_mint_dsc against stale-high prices to mint unbacked DSC, while liquidations also execute at stale prices.

    # oracle_lib.vy
    @> TIMEOUT: constant(uint256) = 72 * 3600

    The code comment itself says "We should use the Chainlink feed heartbeat to determine if a feed is stale or not" — WETH/USD and WBTC/USD Chainlink heartbeats are ~1 hour. The canonical DSCEngine design used a 3-hour timeout; 72h is a 24x weakening of that safety margin.

Risk

  • Reason 1 // Chainlink feed outages/pauses occur periodically on real networks, and oracle problems cluster with market stress events.

  • Reason 2 // A 3-day acceptance window is ample for a crash + oracle outage to coincide, or for an attacker to act while a feed is known to be stale.

  • Impact 1 // Minting of unbacked DSC against stale-high collateral prices -> bad debt / protocol insolvency and stablecoin depeg.

  • Impact 2 // Liquidations executed at stale prices fail to cover debt, compounding the insolvency.

Proof of Concept

Logical PoC (no local Vyper toolchain available): deploy the DSC engine with a MockV3Aggregator whose updated_at = now - 70h; call deposit_collateral_and_mint_dsc and observe the deposit succeeding and minting DSC at the stale price instead of reverting.

Recommended Mitigation

- TIMEOUT: constant(uint256) = 72 * 3600
+ TIMEOUT: constant(uint256) = 1 * 3600

Or better, use per-feed heartbeat values (e.g. 1 hour for WETH/USD and WBTC/USD).

Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 1 hour ago
Submission Judgement Published
Validated
Assigned finding tags:

[M-01] The TIMEOUT is set as a fixed constant of 72 hours, which makes it inflexible in adapting to the market price.

## 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) ```

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!