AI Arena - kartik_giri_47538's results

In AI Arena you train an AI character to battle in a platform fighting game. Imagine a cross between PokΓ©mon and Super Smash Bros, but the characters are AIs, and you can train them to learn almost any skill in preparation for battle.

General Information

Platform: Code4rena

Start Date: 09/02/2024

Pot Size: $60,500 USDC

Total HM: 17

Participants: 283

Period: 12 days

Judge:

Id: 328

League: ETH

AI Arena

Findings Distribution

Researcher Performance

Rank: 56/283

Findings: 2

Award: $120.49

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Awards

111.676 USDC - $111.68

Labels

bug
3 (High Risk)
satisfactory
sufficient quality report
:robot:_49_group
duplicate-68

External Links

Lines of code

https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/FighterFarm.sol#L370

Vulnerability details

In FighterFarm::reRoll function the type of parameter tokenId is mismatched which can lead the function to revert.

Description: The FighterFarm::reRoll function in the FighterFarm contract accepts tokenId as an uint8 parameter, while in most of the protocol the tokenId is of type uint256. The mapping numRerolls which is used inside the FighterFarm::reRoll function also except the tokenId to be the type of uint256 as stated in the below code.

   /// @notice Mapping to keep track of how many times an nft has been re-rolled.
@> mapping(uint256 => uint8) public numRerolls;

Impact: The using of uint8 type for tokenId in the FighterFarm::reRoll function can lead to the potential errors which will cause the revert every time when user try to use reRoll function with the tokenId which exceeds the 255 value.

Proof of Concept: (Proof Of Code)

The below code shows how the call to reRoll function will revert if the tokenId exceeds the value 255.

contract User {
    FighterFarm fighterFarm;

    function reRollExample(uint256 tokenId) external {
        // This call will fail due to parameter type mismatch
@>      fighterFarm.reRoll(tokenId, 0);
    }
}

Recommended Mitigation: Change the tokenId parameter of FighterFarm::reRoll function to be of type uint256 to align with the most of the protocol.

Below code shows the recommended mitigation.

function reRoll(
+    uint256 tokenId,
-    uint8 tokenId,
     uint8 fighterType
     ) public {
    // Rest of Code...
}

Assessed type

DoS

#0 - c4-pre-sort

2024-02-22T01:27:48Z

raymondfam marked the issue as sufficient quality report

#1 - c4-pre-sort

2024-02-22T01:27:54Z

raymondfam marked the issue as duplicate of #68

#2 - c4-judge

2024-03-05T01:57:51Z

HickupHH3 marked the issue as satisfactory

Lines of code

https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/Neuron.sol#L156

Vulnerability details

Issue with Minting Function of Neuron contract.

Description: The Neuron::mint function in the Neuron contract checks if totalSupply() + amount < MAX_SUPPLY before minting new tokens. This condition prevents the total token supply from reaching the maximum supply defined by MAX_SUPPLY.

Impact: As a result of this condition, the token supply cannot reach the maximum supply specified by MAX_SUPPLY.

Proof of Concept: (Proof Of Code)

The below test case shows that we can not reach the MAX_SUPPLY of the token.

   function testMintWithMinterRole() public {
        address minter = vm.addr(3);
        _neuronContract.addMinter(minter);
        uint256 amount = (_neuronContract.MAX_SUPPLY() - _neuronContract.totalSupply());
        console.log("Minting amount is : ", amount);
        vm.prank(minter);
        _neuronContract.mint(minter, amount);
        assertEq(_neuronContract.balanceOf(minter), amount);
         console.log("Minting amount left: ", _neuronContract.MAX_SUPPLY() - _neuronContract.totalSupply());
    }

Output :-

[FAIL. Reason: Trying to mint more than the max supply] testMintWithMinterRole() (gas: 43989)

Recommended Mitigation: To allow the token supply to reach the maximum supply defined by MAX_SUPPLY, the condition in the mint function should be modified to totalSupply() + amount <= MAX_SUPPLY. This change ensures that the maximum supply can be reached without exceeding it.

Below code shows the recommended mitigation.

function mint(address to, uint256 amount) public virtual {
-   require(totalSupply() + amount < MAX_SUPPLY, "Trying to mint more than the max supply");
+   require(totalSupply() + amount <= MAX_SUPPLY, "Trying to mint more than or equal to the max supply");
    // Minting logic...
}

Assessed type

ERC20

#0 - c4-pre-sort

2024-02-21T22:31:00Z

raymondfam marked the issue as insufficient quality report

#1 - c4-pre-sort

2024-02-21T22:31:05Z

raymondfam marked the issue as duplicate of #7

#2 - c4-judge

2024-03-05T02:27:33Z

HickupHH3 changed the severity to QA (Quality Assurance)

#3 - HickupHH3

2024-03-05T02:30:55Z

R #618: R #616: L #614: L #615: L

#4 - c4-judge

2024-03-15T14:14:54Z

HickupHH3 marked the issue as grade-c

#5 - c4-judge

2024-03-20T08:05:12Z

HickupHH3 marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Β© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter