The load function computes a storage slot based on the CUSTOM_REFERRAL_CONFIGURATION_DOMAIN and the customReferralCode input. If there are other contracts or libraries using a similar storage slot determination mechanism, this could lead to unexpected storage collisions.
Code snippet affected:
Copy this code to test folder:
Run forge test --match-contract CustomReferralConfigurationTest -vvv
Output when running:
[FAIL. Reason: revert: uniqueSlot cannot be zero; counterexample: calldata=0xc9164d150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018b0000000000000000000000000000000000000000000000000000000000001322 args=[0x0000000000000000000000000000000000000000000000000000000000000000, 0x000000000000000000000000000000000000018b, 0x0000000000000000000000000000000000001322]] testStorageCollision(bytes32,address,address) (runs: 1, μ: 50252, ~: 50252)
The error message indicates that the test reverted with the message "uniqueSlot cannot be zero". This suggests that the function being tested does not handle the case where uniqueSlot is zero correctly.
High
Storage collisions can lead to severe consequences including data corruption and critical vulnerabilities in the contract. Specifically, if the load function generates a slot that overlaps with slots used by other contracts or libraries, it could inadvertently overwrite important data. This could lead to unpredictable behavior, loss of funds, or even complete failure of the contract's logic. In environments with multiple contracts sharing a storage namespace, the risk of such collisions significantly amplifies the potential impact.
Manual review and Foundry
Implement a more robust storage slot computation or add additional unique identifiers as described in the initial suggestion.
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.