DeFiLayer 1Layer 2
14,723 OP
View results
Submission Details
Severity: high
Invalid

Storage Slot Mismatch in ScrvusdVerifierV1

Summary

  • Incorrect storage slot mapping between the Vyper-based scrvUSD oracle and the Solidity verifier contract.

  • This mismatch causes the verifier to read incorrect data from storage, leading to corrupted price calculations.

Vulnerability Details

The Vyper contract (scrvUSD oracle) assigns storage slots sequentially to its variables:

last_block_number: uint256 # Slot 0
last_prices: uint256[3] # Slots 1-3
price_params: PriceParams # Slots 6-12 (struct members)

The Solidity verifier (ScrvusdVerifierV1) incorrectly assumes slots for price_params start at Slot 21 instead of Slot 6:

PARAM_SLOTS = [0, 21, 22, 20, 38, 39, 40, ...];

total\_debt is read from Slot 21 (actual: Slot 6).

balance\_of\_self uses keccak256 (wrong; Vyper stores it at Slot 12 directly)

Vyper Storage Layout:

Variable | Slot
last_block_number - 0
last_prices[0] - 1
price_params.total_debt - 6
price_params.balance_of_self- 12

Solidity’s Incorrect Slots:

Parameter | Slot Used | Actual Slot
total_debt | 21 | 6
total_idle | 22 | 7
balance_of_self | keccak(...) | 12\

This mismatch causes the verifier to read unrelated data (e.g., other variables or empty slots), leading to garbage values.

Impact

  • Corrupted Price Data: Reading incorrect data, the prices it reports will be wrong and unreliable.

  • Broken Integrations: If the oracle is feeding bad data, these integrations will malfunction or break down.

Tools Used

Manual Code Review.

Vyper Storage Analysis.

Recommendations

Update PARAM_SLOTS in ScrvusdVerifierV1 to match Vyper’s actual slots.

uint256[PROOF_CNT] internal PARAM_SLOTS = [
0, // Filler
6, // total_debt (Slot 6)
7, // total_idle (Slot 7)
8, // total_supply (Slot 8)
9, // full_profit_unlock_date (Slot 9)
10, // profit_unlocking_rate (Slot 10)
11, // last_profit_update (Slot 11)
12 // balance_of_self (Slot 12)
];
Updates

Lead Judging Commences

0xnevi Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

[invalid] finding-incorrect-storage-slot-retrieval

See comments in primary finding in 239

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.