In an upgradeable contract, using a constructor can cause initialization problems because the constructor is only executed once when the contract is deployed, and in the proxy contract mode, the constructor of the logic contract will not be called. In order to ensure that the contract can be initialized correctly after each upgrade, an initializer should be used instead of a constructor.
According to the project's PreMarketsTest, SystemConfig
, CapitalPool
, TokenManager
, PreMarktes
, and DeliveryPlace
belong to the logic contract.
Because the principles are the same, I only use the SystemConfig contract to prove:
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/SystemConfig.sol
https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializers
https://docs.openzeppelin.com/upgrades-plugins/1.x/proxies#the-constructor-caveat
In Solidity, code that is inside a constructor or part of a global variable declaration is not part of a deployed contract’s runtime bytecode. This code is executed only once, when the contract instance is deployed. As a consequence of this, the code within a logic contract’s constructor will never be executed in the context of the proxy’s state.
Modifications to state variables in the constructor of a logic contract will not be reflected in the Proxy contract. For example, if the value of a state variable is modified in the constructor of a logic contract, this modification will not be reflected in the state variable of the Proxy contract. Therefore, constructors cannot be used in upgradeable logic contracts.
Manual review
Modify the Rescuable contract
2.
3.
Valid high severity, since `initializeOwner` is not called for proxy contracts and the constructor for each `Rescuable.sol` contract will not be invoked during proxy deployment, this leaves the `owner` for each proxy unitialized allowing potential to withdraw fund from other proxy contracts inheriting `Rescuable.sol` respectively.
Valid high severity, since `initializeOwner` is not called for proxy contracts and the constructor for each `Rescuable.sol` contract will not be invoked during proxy deployment, this leaves the `owner` for each proxy unitialized allowing potential to withdraw fund from other proxy contracts inheriting `Rescuable.sol` respectively.
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.