After buying three Martenitsa an user can claim one HealthToken
that acts as a ticket to join special events by calling MartenitsaMarketplace::claimReward
. In this function the amount of rewards to mint to the user is calculated using the amount of owned tokens and the previous amount of collected rewards.
The problem is after the amount to rewards is calculated, this amount is used to replaced the amount of rewards claimed, when in reality this amount should be added. This inconsistency between the actual amount claimed and the amount tracked by the contract allows users to take advantage of this to claim infinite rewards.
An attacker can follow the next steps in order to set a convenient state to exploit this vulnerability:
First the attacker buys 3 Martenitsa
The attacker claim rewards
_collectedRewards
is set to 1.
Attacker buys 3 more tokens
Claim rewards again
And this is problem: _collectedRewards
is set again to 1 instead of 2. This happens because the new amount overwrites the old amount and the contract loses track of the amount previously claimed.
To verify the vulnerability paste the following test in MartenitsaMarketplace.t.sol
:
Invariant broken, users can mint inifinite rewards.
Manual review, Foundry
Add the new amount to reward to the previously claimed amount instead of overwriting it.
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.