AI Arena - honey-k12'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: 274/283

Findings: 1

Award: $0.04

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

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

Vulnerability details

Description

The dna parameter in the _createNewFighter function is a crucial part of the fighter creation process.

Currently dna is calculated like this:

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

uint256(keccak256(abi.encode(msg.sender, fighters.length)))

While the keccak256 hash function produces an output that appears random, it’s completely deterministic. This means that given the same input, it will always produce the same output. In this case, the inputs are msg.sender and fighters.length (the current number of fighters). If an attacker knows these two values, they can predict the DNA that will be generated.

Impact

This could potentially be exploited by an attacker to create fighters with specific, possibly advantageous attributes and have an unfair advantage in the game.

Tools Used

Manual Review

To mitigate this, you could introduce additional sources of randomness into the DNA generation process. This would make it much harder for an attacker to predict the DNA.

Assessed type

Other

#0 - c4-pre-sort

2024-02-24T02:02:34Z

raymondfam marked the issue as sufficient quality report

#1 - c4-pre-sort

2024-02-24T02:02:42Z

raymondfam marked the issue as duplicate of #53

#2 - c4-judge

2024-03-06T03:49:26Z

HickupHH3 changed the severity to 3 (High Risk)

#3 - c4-judge

2024-03-06T03:53:24Z

HickupHH3 marked the issue as satisfactory

#4 - c4-judge

2024-03-15T02:10:54Z

HickupHH3 changed the severity to 2 (Med Risk)

#5 - c4-judge

2024-03-22T04:23:06Z

HickupHH3 marked the issue as duplicate of #376

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