In ScrvusdVerifierV1.sol
, the _extractParametersFromProof
function does not check if storage slots exist. If a slot is uninitialized, its value defaults to 0, leading to incorrect parameter extraction and oracle manipulation.
A missing total_supply
can result in a division-by-zero error, leading to contract failures or erroneous price calculations.
The issue here is that the code assigns params[i - 1] = slot.value
without verifying slot.exists
.
If total_supply
(slot 20) is uninitialized, total_supply = 0
, causing division by zero in _raw_price
.
If balance_of_self
(dynamic slot) is uninitialized, unlocked shares will be miscalculated.
This contrasts with the behavior in ScrvusdVerifierV2
, which properly checks for slot existence:
Invalid parameters (e.g., zero total_supply
) cause the oracle to compute erroneous prices, enabling arbitrage attacks or rendering the oracle unusable.
Example: An attacker could trigger a division-by-zero revert in _raw_price
, halting price updates and disrupting dependent systems.
Manual Review
In ScrvusdVerifierV1
, ensure slot.exists
is true for all critical parameters. Revert if any slot is missing.
For non-critical parameters, use default values only if they don’t compromise security.
- Looking at the OOS `StateProofVerifier` and `MerklePatriciaProofVerifier` contract that extracts the slot, the `exists` flag will be flagged as true as long as a non-zero length value is returned as seen [here](https://github.com/curvefi/curve-xdao/blob/3ff77bd2ccc9c88d50ee42d2a746fc7648c7ff2c/contracts/libs/StateProofVerifier.sol#L133C13-L136). From the `MerklePatriciaProofVerifier.extractProofValue`, the minimum length returned will be 1 as represenetd by `bytes(0)`. So this seems to be purely a sanity check that might not even be required. - A slot with zero values is only allowed when the proof provided by the prover correctly proofs that such values are included within the Merkle-Patricia-Tree. The values fetched from mainnet from the V3Vault stored in the merkle trie is likely checked before hand and aggregated into the MerkleTree.
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.