Tadle

Tadle
DeFi
30,000 USDC
View results
Submission Details
Severity: high
Valid

Cross referring can disrupt the referral program

Summary

UserA can set userB as referrer and then userB can set userA as referrer.
This means UserA refers userB and userB refers userA which itself is contradictory as you can't refer someone who refers you.

Vulnerability Details

Github:- https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/SystemConfig.sol#L41

function test_referralContradiction() public {
vm.startPrank(user1);
systemConfig.updateReferrerInfo(user2, 300_000, 0);
vm.stopPrank();
vm.startPrank(user2);
systemConfig.updateReferrerInfo(user1, 300_000, 0);
vm.stopPrank();
console.log("Address of user2: ", user2);
console.log("Referrer of user1: ", systemConfig.getReferralInfo(user1).referrer);
console.log("Address of user1: ", user1);
console.log("Referrer of user2: ", systemConfig.getReferralInfo(user2).referrer);
}

Run this test inside PreMarketsTest

NOTE:- The function updateReferralInfoitself has an error, it's updating the referralInfoof _referrerinstead of msg.sender, so first mitigate that issue to get the correct logs and proof of userA refers userB and userB refers userA

- ReferralInfo storage referralInfo = referralInfoMap[_referrer];
+ ReferralInfo storage referralInfo = referralInfoMap[msg.sender];

Impact

This will disrupts the entire referral program as everyone will use their own referral code, making the referral program useless and less and less people will promote the protocol as they will not get any refferal rewards.

Tools Used

Manual Review

Recommendations

Implement a new check condition inside updateReferralInfofunction, if the _referrer has user as its referrer , then the user can't set _referreras its referrer

Updates

Lead Judging Commences

0xnevi Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-SystemConfig-updateReferrerInfo-msgSender

Valid high severity. There are two impacts here due to the wrong setting of the `refferalInfoMap` mapping. 1. Wrong refferal info is always set, so the refferal will always be delegated to the refferer address instead of the caller 2. Anybody can arbitrarily change the referrer and referrer rate of any user, resulting in gaming of the refferal system I prefer #1500 description the most, be cause it seems to be the only issue although without a poc to fully describe all of the possible impacts

Support

FAQs

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