Users who are not producers and want to get HealthToken
s need to buy 3 different Martenitsa
s in the marketplace in order to be able to claim the token as a reward, the problem is the MartenitsaMarketplace::collectReward
function does not check the designs thus allowing users to claim with identical NFTs.
The docs also state rewards can only be claim every 3 NFTs, but the function neither checks the count
of NFTs is a multiple of 3.
I've created a proof of concept in the form of a test to show the vulnerability, copy and paste the following test in MartenitsaMarketplace.t.sol
:
Protocol invariant broken, identical NFTs can be used to claim rewards.
Manual review, Foundry
MartenitsaMarketplace::collectRewards
needs to be refactor to validate there are not duplicates and the count of NFTs used to claim the rewards is multiple of 3.
The following code snippet shows an example on how the function could be refactored:
The function receives an array of type uint256
as a parameter with the list of token ids the user wants to use to claim the reward. The length of the array is validated to be multiple of 3 so users can only claim using 3, 6, 9 tokens and so on.
Then, to check if there are duplicated NFTs we obtain the hash of the design of the token at the zero index to use it for comparison, later a loop is executed on the rest of the tokens in the array to hash their design and compare each one against the hash of NFT at the zero index. If a duplicate is found the execution reverts.
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.