The ScrvusdOracleV2.vy
contract's update_price()
function accepts a user-provided timestamp (_ts
) without validation. This timestamp is directly used in price calculations and stored in the contract state. Since there are no bounds or sanity checks on this timestamp, it could potentially be manipulated to influence price calculations, even though access to this function is protected by role-based access control.
Severity: Medium
Files Affected:
contracts/scrvusd/oracles/ScrvusdOracleV2.vy
Functions Affected:
update_price()
In the oracle contract, the update_price()
function accepts a timestamp parameter that is used for critical price calculations:
While the function has access control (access_control._check_role(PRICE_PARAMETERS_VERIFIER, msg.sender)
), it doesn't:
Validate that _ts
is reasonably close to block.timestamp
Check that _ts
isn't in the future
Ensure _ts
isn't older than self.price_params.last_profit_update
Additionally, this timestamp is used in price calculations through the _raw_price()
function:
The timestamp affects how unlocked shares are calculated, which in turn impacts the total supply used in the price denominator:
The timestamp manipulation vulnerability could lead to several issues:
Price Manipulation: By providing carefully chosen timestamps, an authorized caller could influence the price calculation, potentially causing prices to be higher or lower than they should be.
Unlocked Shares Calculation: The timestamp directly affects how many shares are considered "unlocked" in the _unlocked_shares()
function, which impacts the total supply used in price calculations.
Inconsistent Protocol State: Using manipulated timestamps could create inconsistencies between the oracle's view of the protocol state and the actual protocol state.
Financial Exploitation: Since the price data from this oracle may be used for financial decisions (like asset valuations, liquidations, etc.), inaccurate prices could lead to direct financial losses for users.
Historical Data Manipulation: A malicious actor could retroactively change how prices are calculated for past periods by using timestamps that don't align with the actual block times.
While the risk is mitigated somewhat by the role-based access control, it remains a significant concern as even authorized callers (including the verifier contracts) could potentially manipulate prices through timestamp selection.
Manual code review
Add Timestamp Validation:
Implement bounds checking to ensure the provided timestamp is reasonable:
Use Block Timestamp Instead:
Consider using the block's timestamp rather than a user-provided one:
Verify Timestamp Against Block:
If the timestamp must be provided (e.g., to match the source block), verify it against block data:
Add Circuit Breaker for Suspicious Price Changes:
Implement a circuit breaker that can be triggered if price changes exceed certain thresholds:
Event Emission for Monitoring:
Add more detailed events to facilitate off-chain monitoring:
By implementing these recommendations, particularly the timestamp validation bounds, the contract would be more resilient against potential manipulation of price calculations through timestamp selection.
- See [here]([https://github.com/CodeHawks-Contests/2025-03-curve?tab=readme-ov-file#blockhash-oracle)](https://github.com/CodeHawks-Contests/2025-03-curve?tab=readme-ov-file#blockhash-oracle) on how it is used to verify storage variable - All state roots and proofs must be verified by the OOS `StateProofVerifier` inherited as `Verifier` (where the price values and params are extracted), so there is no proof that manipulating timestamp/inputs can affect a price update - It is assumed that the OOS prover will provide accurate data and the OOS verifier will verify the prices/max unlock time to be within an appropriate bound/values - There is a account existance check in L96 of `ScrvusdVerifierV1.sol`, in which the params for price updates are extracted from
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.