Closed c4-bot-10 closed 8 months ago
raymondfam marked the issue as sufficient quality report
raymondfam marked the issue as duplicate of #53
HickupHH3 changed the severity to 3 (High Risk)
HickupHH3 marked the issue as satisfactory
HickupHH3 changed the severity to 2 (Med Risk)
HickupHH3 marked the issue as duplicate of #376
Lines of code
https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/FighterFarm.sol#L212-L220 https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/FighterFarm.sol#L252-L260 https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/FighterFarm.sol#L322-L330
Vulnerability details
Description
In Ai Arena, players can create new fighters through
redeemMintPass
,claimFighters
, andmintFromMergingPool
functions, each of which requires providing a dna to_createNewFighter
. However, the calculation of dna in these functions is not entirely random and can lead to unfair outcomes.In both the
mintFromMergingPool
andclaimFighters
functions, dna is calculated based onmsg.sender
and the length of the fighters array. Whilemsg.sender
is predictable because it reflects the address of the entity that initiates the transaction also fighters length is predictable. Thus, attackers can potentially manipulate theirmsg.sender
to influence the resulting dna.Moreover, in the
redeemMintPass
function, dna calculation lacks randomness as the player provides a string to calculate dna, making the result entirely not random.The restricted randomness stemming from the use of the modulo operation on dna for attributes such as weight, element, and physical attributes also contributes to predictability. This makes it simpler for players to exploit these predictable patterns when minting rare attributes.
Players can mint a rare fighter each time they use
redeemMintPass
. However, formintFromMergingPool
andclaimFighters
, they need to wait until the length of the fighters array matches their prediction before minting a token.Impact
Proof of Concept
In this POC, I focused on demonstrating the exploitation of the
redeemMintPass
function for simplicity and only exploit weight and element for simplicity (same for physical attributes) I assume rare attribute are this:To attain these values, a player needs to pass a string that meets the following conditions:
dna % numElemnts == 2
dna % 31 == 5
To obtain this specific string, we can utilize foundry fuzzing.
By utilizing the output string, player can mint fighters with rare attributes.
Tools Used
Manual Review Chisel Foundry
Recommended Mitigation Steps
Get random numbers using Chainlink's VRF.
Assessed type
Other