In ScrvusdVerifierV1.sol
, the _extractParametersFromProof
function extracts scrvUSD
vault parameters from Ethereum state proofs but does not validate that the storage slots actually exist. This allows the function to proceed with zero values for missing or invalid slot proofs, passing potentially incorrect parameters to ScrvusdOracleV2
.
The issue lies in how ScrvusdVerifierV1
handles slot value extraction from state proofs without verifying their existence:
Parameters: PARAM_SLOTS = [0, 21, 22, 20, 38, 39, 40, keccak256(abi.encode(18, SCRVUSD))]
, mapping to [filler, total_debt, total_idle, totalSupply, full_profit_unlock_date, profit_unlocking_rate, last_profit_update, balanceOf(self)]
.
Behavior: If a slot proof is missing or invalid, extractSlotValueFromProof()
returns slot.exists = false, slot.value = 0
. V1 assigns this zero value to params without checking.
Price Distortion
stableswap-ng pools use this price, allowing users to buy scrvUSD cheap and redeem on Ethereum at 1.0.
Manual Code Review
Add Slot Existence Validation:
- 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.