MartenitsaToken:: updateCountMartenitsaTokensOwner
does not have access control: anyone can call this function and can alter the internal accounting of token counts for any address.
MartenitsaToken::updateCountMartenitsaTokensOwner
is supposed to update mapping(address => uint256) public countMartenitsaTokensOwner
whenever a Marenitsa NFT is minted or changes owners. The mapping countMartenitsaTokensOwner
is used for internal accounting and is supposed to reflect how many Martenitsa NFTs are owned by each address (kind of like the standard ERC721
function balanceOf()
). However, since MartenitsaToken::updateCountMartenitsaTokensOwner
does not have any access control and anybody can call it, this internal accounting can be manipulated.
Consider the following test that demonstrates this vulnerability:
Internal accounting (martenitsaToken.countMartenitsaTokensOwner()
) will not reflect true ownership status (martenitsaToken.balanceOf()
).
A malicious user can alter the internal accounting in a way that the contract will think it has a lot more Martenitsa NFTs than it actually does, and then (after meeting all the other requirements for rewards collection) can collect more healthToken
rewards from MartenitsaMarketplace::collectRewards
than it is entitled to.
Manual review, Foundry.
Consider the following options and select whichever matches your current and future requirements more appropriately:
Replace the countMartenitsaTokensOwner
with the the standard ERC721
balanceOf()
, as the former appears to duplicate the functionality already provided by the latter (i.e. tracking the number of tokens owned by each address). In this case you can completely remove not only the mapping but also the updateCountMartenitsaTokensOwner
function.
(According to the protocol owner, this is the less favorable option, the protocol prefers to keep the internal accounting.)
Implement access control for MartenitsaToken::updateCountMartenitsaTokensOwner
by modifying MartenitsaToken.sol
as follows:
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.