The purpose of the HealthToken
token is to serve as a reward mechanism for participants who have more than 3 MartenitsaTokens. For every 3 different MartenitsaTokens they receive 1 HealthToken. Users can also join an event if they have sufficient amount of HealthToken
tokens, where they can become producers during the event and be able to sell their MartenitsaToken
NFTs. However, users can update MartenitsaToken::countMartenitsaTokensOwner
mapping without restriction by calling updateCountMartenitsaTokensOwner
, because it's marked as an external
function. In that way, users can manipulate the contract by:
joining events
becoming producers
becoming sellers to sell their MartenitsaToken
NFTs.
The other problem with this is that users can call MartenitsaMarketplace::collectReward
and receive HealthTokens for every 3 different MartenitsaTokens they own, since collectReward
relies on the MartenitsaToken::countMartenitsaTokensOwner
mapping.
By incrementing their token ID count, users can falsely join events, become producers, and sell MatenitsaToken
NFTs. Also, by incrementing the MartenitsaToken::countMartenitsaTokensOwner
mapping, users can receive infinite HealthTokens by calling MartenitsaMarketplace::collectReward
.
Manual Review
Add this test to MartenitsaMarketplace.t.sol
:
The logs from this test show that Bob increments his token ID count by 3 without restriction, and collects a reward of 1 HealthToken
. Then, he increments his token ID count by 3 again, and collects another reward of 1 more HealthToken
. resulting in owning a total of 2 HealthTokens.
Consider implementing a different logic in MartenitsaToken
and MartenitsaMarketplace
contracts. For instance, the updateCountMartenitsaTokensOwner
function can be removed from the MartenitsaToken
contract, and be implemented as an internal function in the MartenitsaMarketplace
contract. In this way, the MartenitsaMarketplace
contract can control the increment of the token ID count, and the reward mechanism can be implemented in a more secure way.
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.