The ScrvusdVerifierV1.sol
contract contains a critical vulnerability where it extracts storage slot values from Ethereum state proofs without verifying their existence. This allows an actor with the PRICE_PARAMETERS_VERIFIER
role to provide incomplete or partial proofs, leading to default values (zero) being used for key parameters in price calculations. The vulnerability could result in oracle price manipulation, division by zero errors, or incorrect pricing for scrvUSD in StableSwap pools across multiple blockchains.
In ScrvusdVerifierV1.sol
, the _extractParametersFromProof
function extracts parameters from state proofs but fails to verify that the corresponding storage slots actually exist:
The comment "Slots might not exist, but typically we just read them" indicates awareness of the issue but no implementation of proper validation. This is inconsistent with the approach taken in ScrvusdVerifierV2.sol
, which properly checks slot existence:
The critical parameters that can be affected include:
total_debt
(slot 21)
total_idle
(slot 22)
total_supply
(slot 20)
full_profit_unlock_date
(slot 38)
profit_unlocking_rate
(slot 39)
last_profit_update
(slot 40)
balanceOf(self)
(keccak256(abi.encode(18, SCRVUSD)))
This vulnerability is particularly concerning for the total_supply
parameter, as setting it to zero would cause a division by zero error in the price calculation:
Even if the value isn't zero but is significantly lower than the actual value, it could lead to artificially inflated prices.
The impact of this vulnerability includes:
Price Manipulation: An attacker with the PRICE_PARAMETERS_VERIFIER
role can manipulate the oracle price by providing incomplete proofs, causing default values (zero) to be used for critical parameters.
Division by Zero: If total_supply
is set to zero, the price calculation will revert due to division by zero, potentially causing a denial of service in the oracle.
Financial Losses: Incorrect prices fed into StableSwap pools could enable arbitrage opportunities at the expense of liquidity providers.
Cross-Chain Impact: Since this oracle is designed for cross-chain use, manipulated prices could spread across multiple blockchains, amplifying the damage.
The severity is assessed as Medium because:
It requires privileges (PRICE_PARAMETERS_VERIFIER role) to exploit
The smoothening mechanism in the oracle provides some protection against extreme price changes
There are multiple layers where the issue could potentially be caught
The following proof of concept demonstrates how this vulnerability can be exploited. It uses simplified mocks to show the core issue without requiring external dependencies.
When running this test, the output shows that the vulnerability can be successfully exploited:
The root cause of this vulnerability is the lack of validation in the _extractParametersFromProof
function in ScrvusdVerifierV1.sol
. While the extractSlotValueFromProof
function from the StateProofVerifier
library returns both a value and an existence flag, only the value is used without checking if the slot actually exists.
The comment "Slots might not exist, but typically we just read them" suggests awareness of this issue, but proper validation was not implemented. This is inconsistent with ScrvusdVerifierV2.sol
, which properly checks slot existence with require(slot.exists)
.
Manual code review
Static analysis with Slither
Custom test environment for proof-of-concept validation
Vyper compiler version 0.3.7
Add Existence Checks: Modify the _extractParametersFromProof
function to verify that each slot exists before using its value:
Add Parameter Validation: Implement additional validation for critical parameters:
Parameter Relationship Checks: Add validation for logical relationships between parameters:
Consider Implementing Circuit Breaker: Add a mechanism to detect and handle suspicious parameter values:
By implementing these mitigations, the contract will be protected against manipulation through invalid or missing slot proofs, ensuring the integrity of the price oracle across all integrated systems.
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.