Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: high
Valid

Anyone can change referralInfoMap data

Summary

The function SystemConfig.updateReferrerInfo is publicly accessible to all. This means anyone can manipulate data stored in referralInfoMap as long as msg.sender != _referrer.

Vulnerability Details

The referrerInfo.referrerRate can be changed by any user who to reduce the referral rewards for the referrer.

Impact

Referrers rewards distribution will be impacted/reduced.

Tools Used

Manual Review

Recommendations

The mapping referralInfoMap should be split into tow maps. One map should map referee to referrer and referrer to related data such as referrerRate and authorityRate.

The function SystemConfig.updateReferrerInfo should also be split.

Recommended code:

struct ReferralInfo {
uint256 referrerRate;
uint256 authorityRate;
}
mapping(address user => address referrer) public referrersMap;
mapping(address referrer => ReferralInfo) public referrerInfoMap;
function registerReferrer(address _referrer) external {
if (referrersMap[_msgSender()] != address(0x0))
revert ("Referrer already exists");
referrersMap[_msgSender()] = _referrer;
}
function updateReferrerInfo(
uint256 _referrerRate,
uint256 _authorityRate
) external
{
if (totalRate > Constants.REFERRAL_RATE_DECIMAL_SCALER) {
revert InvalidTotalRate(totalRate);
}
if (_referrerRate + _authorityRate != totalRate) {
revert InvalidRate(_referrerRate, _authorityRate, totalRate);
}
ReferralInfo storage referralInfo = referralInfoMap[_msgSender()];
referralInfo.referrerRate = _referrerRate;
referralInfo.authorityRate = _authorityRate;
emit UpdateReferrerInfo(
msg.sender,
_referrer,
_referrerRate,
_authorityRate
);
}

These changes should also reflect at: https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L199-L201

Updates

Lead Judging Commences

0xnevi Lead Judge about 1 year 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.