DeFiLayer 1Layer 2
14,723 OP
View results
Submission Details
Severity: medium
Invalid

Linear Price Smoothing in ScrvusdOracleV2 leading to loss of funds via malicious arbitrage.

Summary

The linear price smoothing algorithm in ScrvusdOracleV2.vy can be manipulated to create predictable price movement patterns that could be exploited by attackers.

The problem is the predictability of price changes. Since:

  1. The price change is purely linear, attackers can precisely predict the smoothed price movement.

  2. No randomness is introduced in smoothing, meaning anyone can anticipate the exact price path.

Vulnerability Details

The oracle uses a linear smoothing function to prevent sharp price changes:

@view
def _smoothed_price(last_price: uint256, raw_price: uint256) -> uint256:
max_change: uint256 = (
self.max_price_increment * (block.timestamp - self.last_update) * last_price // 10**18
)
if unsafe_sub(raw_price + max_change, last_price) > 2 * max_change:
return last_price + max_change if raw_price > last_price else last_price - max_change
return raw_price

Predictable Price Trajectory:

  • The _smoothed_price function enforces a linear adjustment (max_change) based on time since the last update. This creates a deterministic price path that can be calculated by attackers.

  • e.g., If raw_price is 10% higher than the current smoothed price, the oracle will linearly increase its reported price at a predictable rate (governed by max_price_increment).

Impact

This predictable smoothing allows sophisticated attackers to create arbitrage strategies that extract value from the liquidity pools that rely on this oracle, causing losses to liquidity providers.

A malicious actor could:

  • Trade against this known trajectory to extract value from the stableswap pool

  • Front-run or back-run transactions to maximize profit.

  • Consistently extract value from the price movement.

Tools Used

Manual Review

Recommendations

Instead of a linear function, consider implementing a price feed dampening mechanism that uses a time-weighted average price (TWAP) approach

max_change: uint256 = (
self.max_price_increment * last_price // 10**18
) * (block.timestamp - self.last_update) // (some_constant + elapsed_time)

This reduces predictability by dampening price movements over time.

Updates

Lead Judging Commences

0xnevi Lead Judge
5 months ago
0xnevi Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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