A malicious user can abuse the 'sendProfit' function to inflate his profit and later claim more tokens than he should be allowed.
First of all, we should understand how the claiming profit system works.
At the beginning you have to send a certain amount of tokens to the contract:
Note that there is no time limit or user roles to call this function.
Once some tokens are in the contract, users can call claimProfit to get them:
Here it calculates the current profit for user and save it:
saveProfit is an internal function that can be call only when claiming the profit or transfering NFT as it forward a call to _update:
So here is what can be done to steal other user profits.
Before caliming a profit, a malicious user:
Transfer a NFT to your own address or any other under your control to trigger the saveProfit in _Update. Now his profit is equal to totalProfit, or the difference between the last claim and the current one.
Then he calls sendProfit with a small amount just to update the totalProfit value.
And he makes a NFT transfer again to trigger saveProfit. But instead of a 0 value return he will get more tokens:
this small amount will be added to his savedProfit[account]
If he does this several times, he can inflate his profit to the max amount allowed, and claim all tokens stealing from others.
A malicious DAO user can steal profits from other users
Manual review
Consider adding a check for min amount to send to the contract as a profit for users.
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.