MartenitsaToken::countMartenitsaTokensOwner fails to update correctly during every token transfer operation. Certain operations do not trigger the update, making the state variable ineffective.
MartenitsaToken::countMartenitsaTokensOwner should record the token amount owned by a specific user, however, it is not updated in every token transfer operation. For example, the built-in safeTransferFrom function inherit from Oppenzeppelin ERC721 template does not include this operation. Assume Chasy has one Martenitsa token, thus the MartenitsaToken::countMartenitsaTokensOwner value of his account will be 1. However, he can send the token through safeTransferFrom to Bob, instead of using MartenitsaMarketplace::buyMartenitsa, in this case, the MartenitsaToken::countMartenitsaTokensOwner will not be updated correctly. Add the following proof-of-concept in MartenitsaToken.t.sol and run forge test —mt testcountMartenitsaTokensOwnerNotUpdated. The success indicates the value is not properly updated.
Consider the following scenario:
Bob originally has three Martenitsa token, but subsequently transferred to another user. After the operation, Bob can still collect health token as reward through MartenitsaMarketplace::collectReward although he has zero token balance. In this case, although the user has three tokens, but he/she is still unable to collect reward since the MartenitsaToken::countMartenitsaTokensOwner is not updated correctly.
Manual Review, Foundry Testing
Update all the token transfer function to include updateCountMartenitsaTokensOwner operation, or using balanceOf function instead of MartenitsaToken::countMartenitsaTokensOwner, for tracking user token balance. The following is an update example in MartenitsaMarketplace::collectReward:
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.