In the ScrvusdVerifierV1
contract related to the use of an incorrect timestamp surrogate in the verifyScrvusdByStateRoot
function. The function inappropriately uses the last_profit_update
parameter from the SCRVUSD contract as a timestamp when updating the price in the oracle. This substitution creates a significant security risk that could potentially lead to price manipulation and compromise the integrity of the oracle's price feed.
The vulnerability is located in the verifyScrvusdByStateRoot
function:
The issue lies in the use of params[5]
as the timestamp parameter when calling _updatePrice
. According to the contract's configuration, params[5]
corresponds to last_profit_update
from the SCRVUSD contract storage, which is defined in the PARAM_SLOTS
array:
This is problematic because:
last_profit_update
is an internal state variable of the SCRVUSD contract that represents when profits were last updated, not when the block was created.
This value may not align with the actual block timestamp and could be manipulated independently of the blockchain's progression.
The function is inconsistent with verifyScrvusdByBlockHash
, which correctly uses the actual block timestamp.
The impact of this vulnerability is severe:
Price Manipulation: Attackers could potentially manipulate the oracle's price calculations by exploiting the incorrect timestamp, leading to mispriced assets in the ecosystem.
Financial Loss: Since oracles are critical infrastructure for DeFi protocols, any manipulation could result in significant financial losses for users and liquidity providers.
Arbitrage Opportunities: The discrepancy between the actual block timestamp and the last_profit_update
value could create arbitrage opportunities that drain protocol resources.
Ecosystem Instability: Inaccurate price reporting could lead to cascading failures in interconnected DeFi protocols that rely on this oracle.
Temporal Inconsistency: Using different timestamp sources for different verification methods creates an inconsistent state that could lead to unpredictable behavior.
Manual code review
Semantic understanding of the contract's intended behavior
Comparison with similar oracle implementations
Use Actual Block Timestamp: Modify the verifyScrvusdByStateRoot
function to fetch the actual block timestamp from the block hash oracle or another reliable source:
Extend Block Hash Oracle Interface: If the block hash oracle doesn't provide a method to retrieve block timestamps, extend its interface to include this functionality:
Implement Timestamp Verification: Add checks to ensure that timestamps used in price updates are within reasonable bounds and consistent with the blockchain's progression.
Standardize Verification Methods: Ensure that all verification methods use the same source for timestamps to maintain consistency across the system.
Add Circuit Breakers: Implement circuit breakers that can halt price updates if anomalies are detected in the timestamp data.
Add Comprehensive Testing: Develop specific test cases that verify the correct handling of timestamps in all oracle verification methods.
By implementing these recommendations, the contract can mitigate the risk of timestamp manipulation and ensure the integrity of the price feed for the scrvUSD oracle.
See primary comments in issue [228](https://codehawks.cyfrin.io/c/2025-03-curve/judging/228)
- Sponsor Comments - State root oracles usually do not provide block.timestamp, so it's simply not available. That is why last_profit_update is intended. - In `update_price`, this value must be a future block, meaning this update is a state checked and allowed by the OOS verifier contracts. The impact is also increasingly limited given price is smoothen and any updates via the block hash `verifyScrvusdByBlockHash` can also update the prices appropriately, meaning the price will likely stay within safe arbitrage range aligning with protocol logic
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.