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

[H - 1] Misuse of Timestamps in raw_price Function Causing Potential Price Calculation Errors

Summary

There has been found a vulnerability in raw_price function from ScrvusdOracleV2.vy contract.

It accepts two timestamp parameters _ts and _parameters_ts, both defaulting to block.timestamp.
This means that by default, both timestamps represent the current block timestamp when no arguments are provided.

While this might appear reasonable at first glance, using block.timestamp as the default value for these parameters introduces a potential timing issue, particularly because:

_ts is meant to represent the timestamp at which the price should be observed, and _parameters_ts represents the timestamp for the parameters used in the price calculation.
The default block.timestamp for both parameters may lead to inconsistent or outdated prices if these timestamps are meant to reflect different points in time. For example, prices might be calculated at a slightly earlier or later time than intended, resulting in erroneous or outdated price data being used in calculations.

def raw_price(
_i: uint256 = 0, _ts: uint256 = block.timestamp, _parameters_ts: uint256 = block.timestamp
) -> uint256:
"""
@notice Get approximate `scrvUSD.pricePerShare()` without smoothening
@param _i 0 (default) for `pricePerShare()` and 1 for `pricePerAsset()`
@param _ts Timestamp at which to see price (only near period is supported)
"""
p: uint256 = self._raw_price(_ts, _parameters_ts)
return p if _i == 0 else 10**36 // p

Impact

  • Pricing inaccuracy

  • Timestamp exploit

Tools Used

Manual Review

Recommendations

Use time ranges base on the business logic stated in comments

Updates

Lead Judging Commences

0xnevi Lead Judge
6 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.