The initialize()
function, which sets crucial system parameters, can be invoked multiple times by the contract owner.
The initialize()
function is defined as follows:
function initialize(
uint256 _basePlatformFeeRate,
uint256 _baseReferralRate
) external onlyOwner {
basePlatformFeeRate = _basePlatformFeeRate;
baseReferralRate = _baseReferralRate;
}
Key issues:
No initialization guard: The function lacks a mechanism to prevent multiple calls.
Overwritable critical values: basePlatformFeeRate
and baseReferralRate
can be changed arbitrarily and frequently.
Lack of events: Changes to these critical parameters are not logged, reducing transparency.
Frequent changes to base rates could destabilize the entire economic model of the system. Unpredictable changes in fee structures may lead to loss of user confidence. For instance, a user can call get getBaseReferralRate() and get a certain value. After a while, call getBaseReferralRate() again and get a different value due to sudden change by the owner.
And without proper event logging, it's challenging to track changes to these parameters.
Manual review
Implement an initialization guard:
bool private initialized;
function initialize(uint256 _basePlatformFeeRate, uint256 _baseReferralRate) external onlyOwner {
require(!initialized, "Contract is already initialized");
basePlatformFeeRate = _basePlatformFeeRate;
baseReferralRate = _baseReferralRate;
initialized = true;
emit Initialized(_basePlatformFeeRate, _baseReferralRate);
}
Create separate functions for updating these values if needed:
function updateBasePlatformFeeRate(uint256 _newRate) external onlyOwner {
basePlatformFeeRate = _newRate;
emit BasePlatformFeeRateUpdated(_newRate);
}
function updateBaseReferralRate(uint256 _newRate) external onlyOwner {````baseReferralRate = _newRate;````emit BaseReferralRateUpdated(_newRate);````}
The following issues and its duplicates are invalid as admin errors/input validation/malicious intents are1 generally considered invalid based on [codehawks guidelines](https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity#findings-that-may-be-invalid). If they deploy/set inputs of the contracts appropriately, there will be no issue. Additionally admins are trusted as noted in READ.ME they can break certain assumption of the code based on their actions, and
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.