Submitted by DarkTower, also found by alexxander, 0brxce, BoRonGod, 0xDetermination, evmboi32, grearlake, PedroZurdo, BARW, sl1, Krace, Zac, Tricko, Aymen0909, immeas, rouhsamad, sashik_eth, ke1caM, 0xCiphky, MrPotatoMagic, jnforja, 0xBinChook, web3pwn, 0xLogos, bhilare_, Kow, ubl4nk, zxriptor, djxploit, solmaxis69, klau5, haxatron, and ZanyBonzy
When a fighting round ends, winners for the current round get picked and allocated respective rewards. These rewards are fighter NFTs that can be claimed by such winners. When you claim your rewards for a round or several rounds, the numRoundsClaimed state variable which stores the number of rounds youve claimed for gets updated to reflect your claim and each winner can only ever claim up to the amounts they win for each given round. That means if you try to batch-claim for two given rounds for which you won 2 fighter NFTs, your NFT count after the claim should be whatever your current balance of NFT is plus 2 fighter NFTs.
The issue here is that theres a way to mint additional fighter NFTs on top of the fighter NFTs youre owed for winning even though the claimRewards function has implemented a decent system to prevent over-claims. For one, its relatively complex to spoof a call pretending to be the _mergingPoolAddress to mint but a malicious user doesnt need to worry too much about that to mint more fighters; they just need to leverage using a smart contract for engineering a simple reentrancy.
Consider this call path that allows a malicious user to reach this undesired state:
The root cause of this issue stems from the roundId. The amount of times you can reenter the claimRewards function depends on the roundId. So lets say the roundId is 3, it mints 6 NFTs:
Heres a POC to show one such attack path in the code
Place the code in the MergingPool.t.sol test contract and do the setup: testReenterPOC is the attack POC test
Attack contract:
Malicious user leveraging reentrancy test result:
Non-malicious users doing a normal claim result:
Use a nonReentrant modifier for the claimRewards function.
brandinho (AI Arena) confirmed
AI Arena mitigated:
Status: Mitigation confirmed. Full details in reports from niser93, d3e4, and fnanni.
