Users can call MartenitsaToken.sol::updateCountMartenitsaTokensOwner as many times as they wish.
This leads to two scenarios:
Users may increase their MartenitsaToken count without limit, allowing them to receive an unlimited amount of HealthTokens.
Users may decrease the MartenitsaToken count of other users, potentially preventing them from receiving HealthToken rewards.
Bob calls MartenitsaToken::updateCountMartenitsaTokensOwner with his address as owner argument and "add" as operation argument, as many times as he wants to increase his MartenitsaToken count in the MartenitsaToken::countMartenitsaTokensOwner mapping.
When a user calls MartenitsaMarketPlace::collectReward, they receive a HealthToken depending on their MartenitsaToken count.
This function retrieves the user's MartenitsaToken count from the MartenitsaToken::countMartenitsaTokensOwner mapping by invoking MartenitsaToken::getCountMartenitsaTokensOwner.
Since users can increase their MartenitsaToken count without limit, they can receive an unlimited amount of HealthToken.
To continue our example, then Bob will call MartenitsaMarketPlace::collectReward to receive free HealthTokens.
The amount of HealToken that Bob will receive will be the count of his MartenitsaToken divided by 3,
however, that does not really matter, as he can increase his MartenitsaToken count as much as he wants.
Another possible attack is that Bob calls MartenitsaToken::updateCountMartenitsaTokensOwner with "sub" as operation argument and
owner can by any address which has MartenitsaToken. He calls the function as many times untill the address MartenitsaToken count becomes 0.
There are only two ways to get a HealthToken - by winning the MartenitsaVoting or by getting 3 MartenitsaTokens and swapping them for HelathTokens in
MartenitsaMarketPlace.
By letting the users to increase/decrease their and other usres MartenitsaTokens count this can lead to a few problems:
-Practically this means users can mint unlimited amount of HealthTokens, which will lead to their devaluation.
-This will make a fewer producer want to take part of the MartenitsaVoting contest, as the reward(HealthToken) will be meaningless.
-Users can change the MartenitsaTokens count of other users and exclude them from getting their rewards, eventhough they actually could be a MartenitsaToken holders.
Paste this code in MartenitsaMarketPlace and run forge test --match-test testGetUnlimitedRewards -vvv
Manual Review
Unit tests
Remove the MartenistaToken::updateCountMartenitsaTokensOwner function and use ERC721::balanceOf instead.
Or if you want to keep the function -
Add MartenitsaMarketPlace in the MartenitsaToken constructor and add a require in MartenistaToken::updateCountMartenitsaTokensOwner to ensure the function can only be called by the MartenitsaMarketPlace.
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.