AI Arena - Breeje'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: 283/283

Findings: 1

Award: $0.00

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2024-02-ai-arena/blob/main/src/GameItems.sol#L301

Vulnerability details

Impact

Anyone can transfer the GameItems when they are not supposed to, breaks the invariant.

Proof of Concept

GameItems NFT which has transferable attribute set to false are supposed to be not transferable.

To implement it, GameItems currently overrides the safeTransferFrom function and adds a require check to make sure that transferable is set to true. If not, it will revert and not allow transfers.


    function safeTransferFrom(
        address from, 
        address to, 
        uint256 tokenId,
        uint256 amount,
        bytes memory data
    ) 
        public 
        override(ERC1155)
    {
        require(allGameItemAttributes[tokenId].transferable);
        super.safeTransferFrom(from, to, tokenId, amount, data);
    }

But in ERC1155 of openzeppelin, there are couple ways to transfer the NFTs:

  1. Using safeTransferFrom function: Which is correctly override to assert the transferable condition.

  2. Using safeBatchTransferFrom function: This one is not override in GameItems and can be used by anyone to transfer the NFTs.

Hence, anyone can use safeBatchTransferFrom function to transfer the non transferable NFTs.

Tools Used

VS Code

Override the safeBatchTransferFrom implementation as well in GameItems just like how it is done for safeTransferFrom to ensure NFTs are not transferable if transferable attribute is set to false.


+   function safeBatchTransferFrom(
+       address from,
+       address to,
+       uint256[] memory ids,
+       uint256[] memory amounts,
+       bytes memory data
+   ) 
+       public 
+       override(ERC1155)
+   {
+       require(allGameItemAttributes[tokenId].transferable);
+       super.safeBatchTransferFrom(from, to, ids, amounts, data);
+   }

Assessed type

Token-Transfer

#0 - c4-pre-sort

2024-02-22T04:29:16Z

raymondfam marked the issue as sufficient quality report

#1 - c4-pre-sort

2024-02-22T04:29:23Z

raymondfam marked the issue as duplicate of #18

#2 - c4-pre-sort

2024-02-26T00:29:30Z

raymondfam marked the issue as duplicate of #575

#3 - c4-judge

2024-03-05T04:47:38Z

HickupHH3 changed the severity to 3 (High Risk)

#4 - c4-judge

2024-03-05T04:57:03Z

HickupHH3 marked the issue as satisfactory

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