updateReferrerInfo()
is designed to modify referral information. However, there's an issue where the referralInfoMap
mapping sets referralInfo.referrer
to _referrer
instead of msg.sender
(the user who is refering the new user). This causes the rewards to be sent to the wrong address.
updateReferrerInfo()
is implemented as follows.
The inputs can be a bit confusing. In this context, _referrer
doesn't refer to the address of the person who referred the current user, but rather to the user who was referred by the referrer. This becomes clear in PreMarkets.sol
within the createTaker()
, where the referralInfo
is checked as follows.
Given this, it's clear that in the referralInfoMap
mapping, the key represents the referred user, as the referrer will receive a reward for bringing in the new user. When createTaker()
is called by the referred user, it retrieves the referralInfo
to send rewards to the referrer.
With this in mind, it's evident that referralInfo.referrer = _referrer
is incorrectly set, as it should reference the referrer, not the referred user. Instead, it should be set to msg.sender
, representing the user who referred the new user. In the current implementation, all rewards are mistakenly sent to the referred user, which is incorrect. The error is evident in the createTaker()
, where it calls _updateReferralBonus()
to update the rewards.
As you can see in the current implementation, referralInfo.referrer
in the first addTokenBalance()
and msg.sender
in the second one are the same, meaning all the rewards will be sent to the referred user instead of one to the referrer and the other to the referred. This is because referrerReferralBonus
represent the referrer, while authorityReferralBonus
is meant for the referred user (trader).
All the rewards are sent to the referred user, causing the referrer to receive no rewards for bringing in new users. This results in a loss of funds for the referrer.
Manual review.
To resolve this issue, set referralInfo.referrer
to the referrer and not to the referred user.
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
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.