Starklane
ContractThe Starklane
contract is UUPS-upgradeable and ownable , also inheriting state variables from multiple contracts. The use of boolean state variables such as _enabled
and _whiteListEnabled
introduces a risk of storage collision in future versions if the storage layout changes. Instead of using these booleans directly, it is advisable to use implementations like OpenZeppelin's PausableUpgradeable
, which use unique storage locations for these variables to mitigate this risk.
The current implementation of Starklane
uses direct boolean state variables to manage the pause and whitelist functionalities. This approach is prone to storage collisions in future contract upgrades due to the complex inheritance and upgradeable nature of the contract. OpenZeppelin's PausableUpgradeable
contract offers a more robust solution by assigning unique storage slots, reducing the risk of such collisions.
Given the potential for significant issues caused by storage layout changes, it seems more likely that this is a bug rather than an intentional design choice. The need for reliable pausability and whitelist functionalities suggests that a more resilient implementation is necessary.
In future updates, the contract may experience storage collisions, potentially disrupting the pausability
and whitelist
functionalities. This could lead to serious security vulnerabilities, such as the inability to pause the contract during an emergency or failure of the whitelist mechanism, potentially allowing unauthorized access. The integrity and security of the contract could be compromised, leading to financial losses and reputational damage.
The risk can be demonstrated by considering the following scenario:
Deploy the Starklane contract and set initial values for _enabled
and _whiteListEnabled
.
Upgrade the contract to a new version that introduces new state variables, changing the storage layout.
Observe that the storage slots for _enabled
and _whiteListEnabled
may overlap with the new variables, causing unintended behavior.
Manual Review,
To prevent storage collisions in future upgrades, it is recommended to use OpenZeppelin's PausableUpgradeable contract for pausability logic and a similar implementation for whitelist logic. OpenZeppelin's implementation ensures unique storage slot assignments, reducing collision risks. Here’s an example of how to update the contract, the same can be done for whitelist and also the functions which are effected by _enabled should be changed but its ignored here for simplicity.
Please, do not suppose impacts, think about the real impact of the bug and check the CodeHawks documentation to confirm: https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity A PoC always helps to understand the real impact possible.
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.