The MartenitsaMarketplace::_collectedRewards mapping in MartenitsaMarketplace::collectReward is overwritten after everyuse instead of updating allowing anyone who uses the function multiple times to receive more healthtokens than intended
1.Anyone who uses the MartenitsaMarketplace::collectReward function multiple times can receive more healthtokens than intended unknowingly
2. Malicious users can exploit this to steal many more healthtokens
Note: Import {console} in MartenitsaMarketplace.t.sol for Poc to work effortlessly
import {console} from "forge-std/Test.sol";
The user bob interacts with MartenitsaMarketplace::collectReward in 3 transactions every time he buys 3 more MartenitsaTokens and collectsreward:
bobs MartenitsaTokens balance = 3 , _collectedRewards = 1 , healthtokens = 1
bobs MartenitsaTokens balance = 6 , _collectedRewards = 1 , healthtokens = 2
bobs MartenitsaTokens balance = 9 , _collectedRewards = 2 , healthtokens = 4
The healthtokens in transaction 3 for 9 MartenitsaTokens should be 3 but it is 4.
Updating the MartenitsaMarketplace::_collectedRewards mapping correctly
in MartenitsaMarketplace::collectReward function will mitigate the issue.
make the following changes in the MartenitsaMarketplace::collectReward function
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.