Timestamp Manipulation in ScrvusdVerifierV1.sol
The ScrvusdVerifierV1.sol
contract contains a critical vulnerability in how it handles timestamps for price updates. When using the verifyScrvusdByStateRoot
function, the contract uses an untrusted value from the submitted proof data (params[5]
, which is last_profit_update
) as the timestamp parameter for price updates. This allows an attacker to manipulate the timestamp used in price calculations, potentially leading to significant price distortions.
In the ScrvusdVerifierV1.sol
contract, there are two different verification methods:
verifyScrvusdByBlockHash
- Uses the timestamp from the block header
verifyScrvusdByStateRoot
- Uses a parameter from the proof itself as the timestamp
The key vulnerability is in the verifyScrvusdByStateRoot
function:
The issue is that params[5]
(which corresponds to last_profit_update
from scrvUSD) is used as the timestamp parameter when calling the oracle's update_price
function. Unlike verifyScrvusdByBlockHash
, which gets the timestamp from a cryptographically verified block header, this function uses a value directly from the extracted proof parameters, which could potentially be manipulated.
This PoC demonstrates how an attacker could exploit this vulnerability by manipulating the timestamp used in price calculations:
The real impact of this attack comes from how the ScrvusdOracleV2.vy contract uses timestamps in price calculations:
By manipulating the timestamp, an attacker can directly influence the price calculation, creating artificial price movements that would bypass normal time-based smoothing mechanisms.
This vulnerability has severe implications:
Price Manipulation: Attackers can influence the timestamp used in price calculations, leading to incorrect price data across chains.
Temporal Attacks: By manipulating the timestamp, an attacker could create artificial price movements that would normally be restricted by time-based smoothing.
Protocol Security Breakdown: The core purpose of the system is to provide "safe (non-manipulable)" price data, which this vulnerability directly undermines.
Financial Exploitation: As stated in the README, "if someone is able to manipulate this rate, it can lead to the pool being drained from one side."
The impact is particularly severe because the timestamp value has direct influence over how the oracle calculates prices across time, allowing an attacker to artificially accelerate or decelerate price movements in their favor.
The root cause is using untrusted user-supplied data (params[5]
) as a critical timing parameter rather than obtaining the timestamp from a trusted source. While the block and proof verification ensures that the data comes from the correct storage slots, it doesn't ensure that the timestamp is appropriate for price calculation purposes.
This creates an inconsistency in the trust model between the two verification functions, with verifyScrvusdByStateRoot
having a significantly weaker security model than verifyScrvusdByBlockHash
.
Modify verifyScrvusdByStateRoot
to use a trusted timestamp source:
- Anything related to the output by the `BLOCK_HASH_ORACLE` is OOS per \[docs here]\(<https://github.com/CodeHawks-Contests/2025-03-curve?tab=readme-ov-file#blockhash-oracle>). - The PoC utilizes a mock `BLOCK_HASH_ORACLE`which is not representative of the one used by the protocol - Even when block hash returned is incorrect, the assumption is already explicitly made known in the docs, and the contract allows a subsequent update within the same block to update and correct prices - All state roots and proofs must be verified by the OOS `StateProofVerifier` inherited as `Verifier`, so there is no proof that manipulating block timestamp/block number/inputs can affect a price update - There seems to be a lot of confusion on the block hash check. The block hash check is a unique identifier of a block and has nothing to do with the state root. All value verifications is performed by the OOS Verifier contract as mentioned above
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.