Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: high
Invalid

Overwriting existing custom referral codes is possible in Referral::createCustomReferralCode

Summary

The createCustomReferralCode function in the Referral contract allows registered engines to create custom referral codes. However, there is no validation to prevent an existing custom referral code from being overwritten. This allows an attacker to replace the referrer for an existing code, redirecting referral rewards to unauthorized addresses.

Vulnerability Details

function createCustomReferralCode(
address referrer,
string calldata customReferralCode
) external onlyRegisteredEngines {
CustomReferralConfiguration.load(customReferralCode).referrer = referrer;
emit LogCreateCustomReferralCode(referrer, customReferralCode);
}
  • The function does not check if customReferralCode is already assigned.

  • A malicious actor can overwrite an existing referral code and replace the referrer.

Attack Scenario

  1. A legitimate referrer creates a custom referral code (e.g., "BETA123").

  2. An attacker calls createCustomReferralCode(attackerAddress, "BETA123").

  3. The attacker replaces the original referrer, hijacking all future referral rewards.

Impact

  • Rewards meant for one user can be redirected to an unauthorized address.

  • Users may lose confidence in the referral system if their rewards are stolen.

  • Malicious actors can repeatedly overwrite referral codes.

Tools Used

  • Manual Code Review

Recommendations

Modify the function to check if the referral code already exists before assigning a new referrer:

function createCustomReferralCode(
address referrer,
string calldata customReferralCode
) external onlyRegisteredEngines {
CustomReferralConfiguration.Data storage config = CustomReferralConfiguration.load(customReferralCode);
require(config.referrer == address(0), "Referral code already exists");
config.referrer = referrer;
emit LogCreateCustomReferralCode(referrer, customReferralCode);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.