The state variables in the LevelTwo implementation contract are not ordered identically to those in LevelOne, leading to a state variable collision during the UUPS upgrade. This causes the proxy contract to read and write incorrect data when interacting with variables located after the point of divergence in the storage layout, breaking core invariants.
With modified contract (fixing the upgrade), the provided test case test_state_variables_are_the_same_after_graduate()
confirms this data corruption:
It will gets a fail test.
Incorrect Data Reads: Any attempt to access shared state variables in LevelTwo that come after schoolFees
in LevelOne's layout will retrieve data belonging to different variables, resulting in incorrect values.
Broken Invariants: Invariants tied to these misread state variables (like cutOffScore
, bursary
, sessionEnd
) will be broken, leading to unpredictable and erroneous contract behavior.
Logical Errors: Functions in LevelTwo that use these corrupted state variables will operate on bad data, potentially causing severe logical errors, incorrect calculations, or failed transactions.
Loss of State Integrity: The contract's internal state becomes unreliable and inconsistent with the intended data representation.
To fix this, ensure the state variable layout in LevelTwo
perfectly matches the layout of LevelOne
for all variables that exist in both contracts, up to the point where new variables are added in LevelTwo.
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.