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

`amountRewards` variable `rewrites` itself everytime `collectReward` function is used which leads to gaining more HealthTokens

Summary

amountRewards variable rewrites itself everytime collectReward function is used which leads to gaining more HealthTokens.

Vulnerability Details

In MartenitsaMarketplace::collectReward function, after amountRewards is calculated, amountRewards is not added in _collectedRewards variable. Rather, _collectedRewards is rewritten with the current amountRewards. But only the current amountRewards does not account for all the previous rewards collected by the respective user.

Thus, only the immediate previous amountRewards is reduced everytime a user uses collectReward function to collect HealthTokens, which enables the user to gain HealthTokens much more than it is intended.

Impact

Users will be able to obtain more HealthTokens then it is intended by the protocol.

Tools Used

Manual Review

Recommendations

Add code in MartenitsaMarketplace::collectReward function:

- _collectedRewards[msg.sender] = amountRewards;
+ _collectedRewards[msg.sender] += amountRewards;
Updates

Lead Judging Commences

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

_collectedRewards is not updated correctly

Support

FAQs

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