Tadle

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

anyone can override other users referral Info

Summary

A portion of the tx fees usually is split between the protocol and referrers . However, everyone can set themselves as a referrer from another owned EOA which even does not participate in the protocol.

Vulnerability Details

When a user calls PreMarkets.createTaker(), it needs to pay a platform fee. However if the user is a refferer to someone else, the fee is less(usually 30%).

https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L203

https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L254-L260

ReferralInfo memory referralInfo = systemConfig.getReferralInfo(
_msgSender()
);
uint256 remainingPlatformFee = _updateReferralBonus(
platformFee,
depositAmount,
stockAddr,
makerInfo,
referralInfo,
tokenManager
);

However the setting of referrer config logic is flawed and anyone can set themselves as a referrer. The user needs to call SystemConfig.updateReferrerInfo() from another EOA(to bypass the validation). The other EOA does not even need to participate in the protocol.

https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/SystemConfig.sol#L69

function updateReferrerInfo(
address _referrer,
uint256 _referrerRate,
uint256 _authorityRate
) external {
if (_msgSender() == _referrer) { //@< validation will be skippep if the same user calls from another EOA, that even does not participate in the project
revert InvalidReferrer(_referrer);
}
//... skipped code blocks
//
ReferralInfo storage referralInfo = referralInfoMap[_referrer];// @< issue: should be msg.sender instead of _referrer
referralInfo.referrer = _referrer;
referralInfo.referrerRate = _referrerRate;
referralInfo.authorityRate = _authorityRate;
//... skipped code blocks
}

Impact

Protocol loses fees because all users can set themselfs as refferers from another EOA.

Tools Used

Manual review

Recommendations

Change here: https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/SystemConfig.sol#L69

- ReferralInfo storage referralInfo = referralInfoMap[_referrer];
+ ReferralInfo storage referralInfo = referralInfoMap[msg.sender];
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.