Open c4-bot-1 opened 9 months ago
raymondfam marked the issue as duplicate of #1641
HickupHH3 changed the severity to 2 (Med Risk)
HickupHH3 changed the severity to 3 (High Risk)
HickupHH3 changed the severity to 2 (Med Risk)
HickupHH3 marked the issue as satisfactory
HickupHH3 marked the issue as selected for report
Have commented on this vulnerability in the initial primary issue #1641.
brandinho (sponsor) confirmed
Mitigated here
A few months ago, I made what felt like the worst mistake of my life, I lost access to my Bitcoin wallet containing a staggering $500,000 worth of BTC. Yes, you heard that right: half a million dollars! This wasn’t just an amount of money; it was my life savings, my retirement fund, and my secret stash for that dream vacation to a tropical island, goodbye, piña coladas! The stress was unbearable, and my sleep schedule? Well, let’s just say I was starting to resemble a zombie auditioning for a horror movie. I was too ashamed to tell my family. I mean, who wants to explain to their parents that their golden goose turned into a rusty old chicken? Instead, I confided in a close friend, who immediately recommended ADRIAN LAMO HACKER. He’d heard about them through a colleague who had experienced a similar disaster. At first, I was skeptical—after all, I had the same faith in my old flip phone’s battery life during a three-hour movie marathon. But desperate times call for desperate measures, so I decided to give them a shot. When I reached out to ADRIAN LAMO HACKER Via email: Adrianlamo@consultant.com/ WhatsApp: +1 (909) 739‑0269/ Telegram username: @ADRIANLAMOHACKERTECH, I was pleasantly surprised by their professionalism. They didn’t promise me the moon or that I’d be sipping cocktails in the Bahamas by sunset. Instead, they assured me they would do their best, which, let’s be honest, was way more reassuring than my uncle’s “It’ll all work out” mantra during family gatherings. Their calm approach gave me hope, even when I was pretty sure my Bitcoin had taken an extended vacation without me. Throughout the recovery process, they kept me updated at every turn. I felt like I was in a reality show, except the only drama was my anxiety levels and my ever-growing collection of stress snacks. Finally, after a few nail-biting days that felt like years in a time loop, I got the message I had been praying for—they had recovered my wallet! When I logged in and saw my balance fully restored, I broke down in tears—happy tears, mind you, not the kind you shed when you accidentally step on Lego. ADRIAN LAMO HACKER didn’t just recover my funds; they saved my sanity, my future, and my tropical vacation plans. If you ever find yourself in a similar situation, trust me: these folks know what they’re doing. They’ll have you back in control faster than you can say, “Where’s my Bitcoin?!”
Lines of code
https://github.com/code-423n4/2024-02-ai-arena/blob/1d18d1298729e443e14fea08149c77182a65da32/src/RankedBattle.sol#L285-L286 https://github.com/code-423n4/2024-02-ai-arena/blob/1d18d1298729e443e14fea08149c77182a65da32/src/RankedBattle.sol#L495-L496
Vulnerability details
Impact
Cannot record a user's victory on-chain, and it may be possible to recover past losses(which should impossible).
Proof of Concept
If you lose in a game,
_addResultPoints
is called, and the staked tokens move to the StakeAtRisk.If a Fighter NFT has NRN tokens staked, that Fighter NFT is locked and cannot be transfered. When the tokens are unstaked and the remaining
amountStaked[tokenId]
becomes 0, the Fighter NFT is unlocked and it can be transfered. However, it does not check whether there are still tokens in the StakeAtRisk of the Fighter NFT.Unstaked Fighter NFTs can now be traded on the secondary market. Suppose another user buys this Fighter NFT with remaining StakeAtRisk.
Normally, if you win a game, you can call
reclaimNRN
to get the tokens back from StakeAtRisk.However, if a new user becomes the owner of the Fighter NFT, it does not work as intended.
The
_addResultPoints
might revert due to the underflow atreclaimNRN
'samountLost[fighterOwner] -= nrnToReclaim
. Therefore, the new owner cannot record a victory on-chain with the purchased NFT until the end of this round.Even if the new owner already has another NFT and has a sufficient amount of
amountLost[fighterOwner]
, there is a problem.There is a problem even if the user owns a sufficient amount of
amountLost[fighterOwner]
and does not have stakeAtRisk of another NFT in the current round. In this case, the user can steal the protocol's token.amountLost[fighterOwner]
is a total amount regardless of rounds, it remains 100 even after the round.This is PoC. You can add it to StakeAtRisk.t.sol and run it.
amountLost
0 cannot record a victory with the purchased NFT due to underflow.Tools Used
Manual Review
Recommended Mitigation Steps
Tokens with a remaining StakeAtRisk should not be allowed to be exchanged.
Assessed type
Invalid Validation