The storage variable mapping(address => uint256) public countMartenitsaTokensOwner;
is intended to keep track of the number of tokens owned by a given address.
The function updateCountMartenitsaTokensOwner
is meant to update the aforementioned storage variable while transferring tokens between addresses. It decreases the token amount held by the sender and increases it for the receiver.
The issue with the current implementation is that it allows anybody to call the function with any address and operation as parameters, breaking the accountability system.
The function MartenitsaToken::updateCountMartenitsaTokensOwner
does not impose any restrictions on who can call it, thus breaking the accountability of the countMartenitsaTokensOwner
storage variable.
Proof of concept
Call MartenitsaToken::getCountMartenitsaTokensOwner(address)
for a given target address to know the number of NFTs owned by that address.
Call updateCountMartenitsaTokensOwner()
passing the target address and the operation add.
Calling MartenitsaToken::getCountMartenitsaTokensOwner(address)
for the target address should increase by one.
Place the following code in MartenitsaToken.t.sol
. It manages to increase the number of owned NFTs without actually minting a new one.
Incorrect ownership info accounting.
The value returned by MartenitsaToken::getCountMartenitsaTokensOwner
cannot be trusted.
Both MartenitsaMarketplace::buyMartenitsa
and MartenitsaMarketplace::makePresent
could be exploited by repeatedly calling updateCountMartenitsaTokensOwner(targetAccount, "sub")
for a given targetAccount
until countMartenitsaTokensOwner[targetAccount]
reaches zero. This will prevent the targetAccount from selling or transferring any tokens.
Manual review.
No need to implementcountMartenistaTokensOwner
to keep track of the number of tokens held by each user. Use ERC721
keeps track of it internally and the amount of tokens can be fetch viaERC721::balanceOf
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.