The initialize
function of the contract sets the starknetCoreAddress
without verifying that it is a valid, non-zero contract address. Since their is no other function to set the starknetCoreAddress
after initialization, any mistake or malicious input can lead to the contract being permanently compromised or non-functional.
In the provided initialize
function, the starknetCoreAddress
is set directly from the input data without any validation checks to ensure that it is a valid contract address. This presents several risks:
Zero Address Risk: If starknetCoreAddress
is set to the zero address (0x0000000000000000000000000000000000000000
), either intentionally or not, it would likely cause the contract to malfunction since any interactions with this address would fail.
Non-Contract Address Risk: If starknetCoreAddress
is set to an address that is not a smart contract, any calls made to this address under the assumption that it is a contract would fail, leading to errors or failures in the contract's functionality.
Immutable State: Once the starknetCoreAddress
is set during initialization, it cannot be changed as their is not such functionality to reset it. This makes it crucial to ensure that the address is valid at the time of initialization to avoid permanently compromising the contract.
If the starknetCoreAddress
is set to an invalid or incorrect address:
Operational Failure: The contract could fail to interact with the StarkNet protocol as intended, leading to loss of functionality.
Irreversible State: Since the address is immutable post-initialization, any error in setting this address cannot be corrected, potentially rendering the contract useless.
Manual code review
Validation of starknetCoreAddress
:
Add a check to ensure that starknetCoreAddress
is not the zero address.
Verify that starknetCoreAddress
is a contract address by checking its code size:
Consider adding a function to update starknetCoreAddress
:
If possible, consider adding a function that allows the contract owner to update starknetCoreAddress
in case it was incorrectly set during initialization.
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.