Tadle

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

[M-2] `SystemConfig::updateReferrerInfo`'s `_referrer != _msgSender()` check can easily be bypassed

Description:

According to the natspec of updateReferrerInfo() the function is not supposed to be called by the referrer, so that
people don't go on setting referral for themselves.

Code snippet:
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/SystemConfig.sol#L38-L52

/**
* @notice Update referrer setting
* @param _referrer Referrer address
* @param _referrerRate Referrer rate
* @param _authorityRate Authority rate
* @notice _referrerRate + _authorityRate = baseReferralRate + referralExtraRate
* @notice _referrer != _msgSender()
*/
function updateReferrerInfo(
address _referrer,
uint256 _referrerRate,
uint256 _authorityRate
) external {
if (_msgSender() == _referrer) {
// @audit this can be bypassed
revert InvalidReferrer(_referrer);
}
if (_referrer == address(0x0)) {
revert Errors.ZeroAddress();
}
// rest of the code
}

However, anyone user can simply use another wallet address to bypass this system and set referral for themselves.

Impact:

This will cause severely impact the protocol as none of the users will be able earn any authorityRate

Given that authorityRate can be highly incentivised by the referrer so that more and more users use their referral link, this will break the system.

Proof of Concept:

Suppose user1 wants to call updateReferrerInfo with referrer as user1 and then the corresponding authorityRate and referrerRate, as per the code snippet this will be prevented.

However, user1 can simply use another wallet, lets call it cibilWallet and use that wallet to call the function.
In this case the _msgSender() will be cibilWallet where as the referrer will be user1 and this will pass.

This breaks the intended functionality of the protocol.

Recommended Mitigation:

One solution could be that instead of users setting the referral information, the referrers should set this information and then add the referred people to a mapping referrerToReferred, this mapping can then be used to validate such referral data.

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.