The update_price
function in the ScrvusdOracleV2.vy
contract accepts critical price parameters without performing any validation, allowing privileged users to set arbitrary values that could manipulate prices or cause denial of service.
The vulnerability exists in the update_price
function:
The issue stems from the lack of validation of the _parameters
array before storing the values in the contract state. While the function does include an access control check to ensure only authorized callers can update parameters, it doesn't:
Validate that the parameters fall within reasonable bounds
Check for logical consistency between related parameters (e.g., total_supply ≥ balance_of_self)
Ensure that changes from previous values are within acceptable limits
Verify that the provided timestamp (_ts) is reasonable
These parameters directly influence the price calculation through the _raw_price
function and are used throughout the contract.
This vulnerability could lead to several serious consequences:
Price Manipulation: An attacker with the PRICE_PARAMETERS_VERIFIER
role could set parameters to manipulate the calculated price of scrvUSD, potentially impacting dependent protocols and users.
Denial of Service: Certain combinations of parameters could cause computational errors or reverts in functions that use these parameters, making the oracle unusable.
Economic Exploits: If integrated with other DeFi protocols, price manipulation could create arbitrage opportunities or allow exploitative trades.
Breaking Logical Invariants: Setting inconsistent parameters could break expected relationships between values, causing unpredictable behavior throughout the contract.
The risk is elevated because there are no circuit breakers or bounds that would prevent extreme manipulation of these critical values.
Manual code review
Analysis of contract business logic
Review of function behaviors and dependencies
Implement Parameter Validation:
Add Rate Limiting:
Implement Oracle Guards:
Add Time-Based Validation:
Consider a Multi-Oracle Setup:
Implement a system where multiple independent oracles must agree on parameter changes that exceed certain thresholds.
Add Emergency Functions:
Implement functions that allow admins to reset parameters to safe values in case of manipulation.
By implementing these recommendations, the contract would be better protected against parameter manipulation while maintaining its core functionality.
- 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.