The createCustomReferralCode
function in the GlobalConfigurationBranch contract lacks an existence check when creating new custom referral codes. While the risk of unauthorized overwrites is mitigated by access control, the absence of an on-chain existence check could lead to accidental overwrites, potentially impacting the integrity of the referral system in the Zaros protocol.
The vulnerability exists in the createCustomReferralCode
function.
While the function is protected by the onlyOwner
modifier, it lacks checks for:
Existence of the referral code
Validity of the referral code (length, character set)
Non-zero referrer address
Accidental overwrites, depending on the owner's management processes.
Despite the low probability, the potential impact could be significant:
Accidental overwriting of existing referral relationships
Potential for referral code "theft"
Reduced integrity and reliability of the referral system
Possible economic implications due to incorrect reward distributions
In the context of Zaros, a financial protocol dealing with perpetual futures trading, even low-probability risks warrant mitigation due to the potential financial implications.
Manual Review
Despite the low probability, implementing an existence check is still highly recommended because:
It provides an additional layer of security against both malicious and accidental overwrites.
It enforces good practices and reduces reliance on off-chain processes to track and manage referral codes.
The cost of implementing this check is minimal compared to the potential impact of an overwrite.
It aligns with the principle of defense in depth in security design.
To address this vulnerability, implement comprehensive checks in the createCustomReferralCode
function. Here's an improved version of the function incorporating best practices:
This implementation addresses the following:
Checks for zero address referrer
Enforces a minimum length for referral codes
Prevents duplicate referral codes using a mapping
Ensures referral codes only contain alphanumeric characters
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.