Critical
The LevelOne and LevelTwo contracts have incompatible storage layouts, which will cause severe data corruption during upgrade. This will result in:
Loss of critical school fee data
Misalignment of all state variables (values will be assigned to incorrect variables)
Complete loss of review tracking functionality (mappings missing in LevelTwo)
Potential fund misallocation during graduation
Permanent corruption of contract state with no recovery method
These issues compromise the entire functionality of the upgraded contract and will lead to immediate financial loss as funds are transferred to incorrect addresses or become permanently locked.
When upgrading from LevelOne to LevelTwo using the UUPS pattern, the storage layout must remain compatible to preserve data integrity. However, several critical variables are missing or reordered in LevelTwo:
In LevelOne, the storage variables begin with:
In LevelTwo, the variables are:
The missing schoolFees
variable creates a ripple effect where all subsequent storage slots become misaligned. After upgrade, the following critical data corruption will occur:
sessionEnd
in LevelTwo will contain the value of schoolFees
from LevelOne
bursary
will contain the value of sessionEnd
, meaning the financial accounting for the system is completely broken
cutOffScore
will contain the value of bursary
, meaning student graduation requirements become whatever the bursary amount was
All teacher and student data will be shifted, causing cross-contamination between mappings
The 60% of bursary funds meant to be carried forward will be accessible in the wrong storage slot
Since this storage collision affects financial data and access controls, it represents a catastrophic failure mode for the entire system.
To preserve storage compatibility:
Ensure LevelTwo declares all variables in the exact same order as LevelOne, even if they're unused:
Add back the missing mappings:
Consider using OpenZeppelin's StorageSlot library or the more recent ERC-7201 Namespaced Storage Layout pattern for better storage management.
Add extensive tests to verify storage compatibility between contract versions.
A PoC isn't necessary as this is a deterministic storage layout issue that can be verified through code inspection alone. The corruption occurs at upgrade time and is irreversible once executed.
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.