The ScrvusdVerifierV1
contract incorrectly calculates the storage slot for the balanceOf
mapping, causing it to read from the wrong location in the scrvUSD
contract's storage. This results in the oracle using an incorrect (likely zero) value for balance_of_self
, which affects price calculations.
In Ethereum's storage layout, the correct way to calculate a storage slot for a mapping at position p with key k is:
However, in ScrvusdVerifierV1, the contract reverses this order when calculating the slot for balanceOf:
The comment indicates that slot 18 is the balanceOf mapping and SCRVUSD is the address whose balance we want to read. The correct calculation should be:
Since the parameters are reversed in the calculation, the verifier will read from an entirely different storage slot than intended. This slot is likely to contain zero or some unrelated value.
This vulnerability impacts the accuracy of price calculations in the oracle system:
The balance_of_self
parameter is used in several critical calculations:
In _obtain_price_params
to calculate gain:
In _unlocked_shares
to determine unlocked shares when all profits are unlocked:
These calculations directly influence the price of scrvUSD on the target chain.
Using an incorrect (likely zero) balance_of_self value would:
Underestimate the calculated gain per period
Incorrectly report unlocked shares
Eventually lead to undercalculation of the scrvUSD price
This results in a lower-than-actual price for scrvUSD on the target chain, potentially allowing users to buy scrvUSD at a discount compared to its true value.
Manual code review
Correct the storage slot calculation by reversing the parameter order:
- Per sponsor comments, verified slot is vyper, solidity contract only verifies it. - Vyper computes storage slots different from solidity as seen [here](https://ethereum.stackexchange.com/questions/149311/storage-collision-in-vyper-hashmap)
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.