Anyone can call the updateReferrerInfo function of the SystemConfig contract, thereby stealing the platform's earnings
The SystemConfig contract has an updateReferrerInfo function that allows users to set _referrerRate value for any address.
The main requirements in the updateReferrerInfo function are:
msg.sender address must not be _referrer address
The expression _referrerRate + _authorityRate = baseReferralRate + referralExtraRate must be met
Let's look at how you can get around these conditions:
The first condition is simple, we just need to send the transaction not from the _referrer address, for simplicity we can use different relayers or custom smart contracts.
The default value of referralExtraRate for all addresses is 0, so next consider the expression _referrerRate + _authorityRate = baseReferralRate. Since there is a check on the contract that _referrerRate must be at least as large as baseReferralRate, our expression will simplify to the simple form _referrerRate = baseReferralRate. So the values we pass to the function must be _referrerRate = baseReferralRate and _authorityRate = 0.
So any address can steal 30% (baseReferralRate value) of the platform's rewards.
Simply add the test to the PreMarkets.t.sol file and run the tests.
To check the platformFee value without exploiting the vulnerability, lines 27 and 28 should be commented out
Thanks to the vulnerability, every user can steal 30% (baseReferralRate value) of the platform's earnings effortlessly.
The vulnerability was discovered through a manual audit of contract code. A unit test was also written, which confirms the existence of the vulnerability.
You can add a check to prevent anyone from calling the updateReferrerInfo function.
The second option is to change the checks inside the updateReferrerInfo function so that the user cannot set _referrerRate without referralExtraRate or cannot pass _referrerRate == baseReferralRate
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.