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
Rank: 202/283
Findings: 4
Award: $2.49
π Selected for report: 0
π Solo Findings: 0
π Selected for report: CodeWasp
Also found by: 0x13, 0xAlix2, 0xAsen, 0xCiphky, 0xE1, 0xLogos, 0xaghas, 0xlemon, 0xlyov, 0xvj, ADM, Aamir, BARW, Bauchibred, DMoore, DanielArmstrong, Draiakoo, Fulum, GhK3Ndf, Josh4324, Kalogerone, KmanOfficial, Krace, KupiaSec, Limbooo, MidgarAudits, MrPotatoMagic, PedroZurdo, Pelz, Tendency, _eperezok, adam-idarrha, al88nsk, alexxander, alexzoid, aslanbek, blutorque, btk, c0pp3rscr3w3r, cartlex_, cats, d3e4, deadrxsezzz, denzi_, devblixt, dimulski, erosjohn, evmboi32, fnanni, grearlake, hulkvision, immeas, israeladelaja, jaydhales, jesjupyter, jnforja, juancito, klau5, korok, ktg, ladboy233, matejdb, merlinboii, novamanbg, nuthan2x, oualidpro, peanuts, petro_1912, pkqs90, pynschon, radev_sw, rouhsamad, sashik_eth, shaka, sobieski, soliditywala, stackachu, tallo, thank_you, ubl4nk, vnavascues, web3pwn, xchen1130, zhaojohnson
0.1044 USDC - $0.10
Fighters in FighterFarm can be transferred even if there is some staking related with this fighter
In FighterFarm.sol, fighters cannot be transferred in some cases. FighterFarm has already override below functions in Openzepplin ERC721 to prevent token transferred:
function transferFrom(address from, address to, uint256 tokenId); function safeTransferFrom(address from, address to, uint256 tokenId);
In Openzepplin's implementation, there is another function which can transfer tokens:
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data)
If Alice has one fighter(ERC721) and has some staking in RankedBattle and this fighter should not be transferred, Alice can call safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) to transfer this fighter to Bob. Alice will lose her staking in RankedBattle.
Manual
Override function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data), add transfer limitation.
Access Control
#0 - c4-pre-sort
2024-02-23T04:31:02Z
raymondfam marked the issue as insufficient quality report
#1 - c4-pre-sort
2024-02-23T04:31:11Z
raymondfam marked the issue as duplicate of #54
#2 - c4-pre-sort
2024-02-23T04:47:14Z
raymondfam marked the issue as duplicate of #739
#3 - c4-pre-sort
2024-02-23T04:52:18Z
raymondfam marked the issue as sufficient quality report
#4 - c4-judge
2024-03-11T02:39:28Z
HickupHH3 marked the issue as satisfactory
π Selected for report: Aamir
Also found by: 0rpse, 0x11singh99, 0x13, 0xAlix2, 0xAsen, 0xBinChook, 0xCiphky, 0xE1, 0xKowalski, 0xLogos, 0xWallSecurity, 0xaghas, 0xbranded, 0xlemon, 0xlyov, 0xpoor4ever, 0xprinc, 0xvj, ADM, Aymen0909, BARW, Bauchibred, Breeje, CodeWasp, DMoore, DeFiHackLabs, Draiakoo, Fulum, GhK3Ndf, Greed, Jorgect, Josh4324, Kalogerone, KmanOfficial, Krace, Limbooo, McToady, MidgarAudits, MrPotatoMagic, PedroZurdo, Pelz, Ryonen, SovaSlava, SpicyMeatball, Tendency, Timenov, ZanyBonzy, _eperezok, al88nsk, alexxander, alexzoid, aslanbek, blutorque, btk, cartlex_, cats, csanuragjain, deadrxsezzz, denzi_, devblixt, dimulski, djxploit, erosjohn, evmboi32, fnanni, grearlake, haxatron, hulkvision, immeas, israeladelaja, jaydhales, jesjupyter, jnforja, josephdara, juancito, kiqo, klau5, korok, krikolkk, ktg, kutugu, ladboy233, lil_eth, m4ttm, matejdb, merlinboii, n0kto, ni8mare, novamanbg, nuthan2x, oualidpro, pa6kuda, peter, petro_1912, pkqs90, pynschon, sandy, sashik_eth, shaflow2, shaka, sobieski, soliditywala, solmaxis69, stackachu, tallo, thank_you, tpiliposian, ubl4nk, visualbits, vnavascues, web3pwn, xchen1130, zhaojohnson
0.0037 USDC - $0.00
GameItems' transferable can be bypassed.
In GameItems.sol, ERC1155 Token can be set transferable or non-transferable. If Token id is set non-transferable, tokenId should not be transferred. In current implementation, we've already added one require to prevent token transferred in function 'safeTransferFrom()'
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); }
GameItems is based on Openzepplin ERC1155. ERC1155 has another function to transfer tokens.
function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); }
If users want to transfer tokens which expected to be non-transferable, users can call safeBatchTransferFrom() to transfer tokens, which is unexpected by system.
Manual
Override function safeBatchTransferFrom(), add transferable check.
Token-Transfer
#0 - c4-pre-sort
2024-02-22T03:41:11Z
raymondfam marked the issue as sufficient quality report
#1 - c4-pre-sort
2024-02-22T03:41:54Z
raymondfam marked the issue as duplicate of #18
#2 - c4-pre-sort
2024-02-26T00:27:42Z
raymondfam marked the issue as duplicate of #575
#3 - c4-judge
2024-03-05T04:47:39Z
HickupHH3 changed the severity to 3 (High Risk)
#4 - c4-judge
2024-03-05T04:52:10Z
HickupHH3 marked the issue as satisfactory
π Selected for report: Abdessamed
Also found by: 0rpse, 0xAlix2, 0xAsen, 0xCiphky, 0xlemon, 0xmystery, 0xvj, ADM, Aamir, Archime, BARW, DarkTower, Draiakoo, FloatingPragma, JCN, McToady, MrPotatoMagic, OMEN, PetarTolev, Ryonen, SpicyMeatball, Tendency, VAD37, Velislav4o, VrONTg, Zac, adamn000, ahmedaghadi, alexxander, alexzoid, bhilare_, btk, cats, d3e4, denzi_, devblixt, dimulski, evmboi32, fnanni, givn, haxatron, immeas, jesjupyter, juancito, ke1caM, klau5, korok, krikolkk, matejdb, n0kto, niser93, peter, pkqs90, radin100, shaka, sl1, soliditywala, stackachu, stakog, t0x1c, vnavascues, yotov721, zhaojohnson
1.2667 USDC - $1.27
users can choose wanted fighterType when redeemMintPass()
In AAMintPass::claimMintPass(), when users want to claim his/her pass via signature, it contains different type fighters' amount.
function claimMintPass( uint8[2] calldata numToMint, bytes calldata signature, string[] calldata _tokenURIs ) external { require(!mintingPaused); bytes32 msgHash = bytes32(keccak256(abi.encode( msg.sender, numToMint[0], numToMint[1], passesClaimed[msg.sender][0], passesClaimed[msg.sender][1], _tokenURIs ))); require(Verification.verify(msgHash, signature, delegatedAddress)); uint16 totalToMint = uint16(numToMint[0] + numToMint[1]); require(_tokenURIs.length == totalToMint); passesClaimed[msg.sender][0] += numToMint[0]; passesClaimed[msg.sender][1] += numToMint[1]; for (uint16 i = 0; i < totalToMint; i++) { createMintPass(msg.sender, _tokenURIs[i]); } }
In FighterFarm::redeemMintPass(), if users want to redeem pass to generate one fighter, users can choose any wanted fighter type.
For example,
Alice is allowed to claim pass with one Champion pass and one Dendroid pass.
Alice claims them via her verified signature. (eg, tokenid(1), tokenid(2))
Alice calls redeemMintPass() to generate 2 fighters. The input parameter fighterTypes is set as [1, 1]
Alice will get two Dendroid types' fighter. However, in the beginning, Alice has only one Champion pass and one Dendroid pass.
Manual
Invalid Validation
#0 - c4-pre-sort
2024-02-22T07:44:42Z
raymondfam marked the issue as sufficient quality report
#1 - c4-pre-sort
2024-02-22T07:44:50Z
raymondfam marked the issue as duplicate of #33
#2 - c4-pre-sort
2024-02-26T00:53:26Z
raymondfam marked the issue as duplicate of #1626
#3 - c4-judge
2024-03-06T03:09:28Z
HickupHH3 marked the issue as satisfactory
π Selected for report: klau5
Also found by: 0xAleko, 0xAlix2, 0xAsen, 0xCiphky, 0xKowalski, 0xlemon, 0xvj, 14si2o_Flint, Aamir, AlexCzm, Aymen0909, BARW, Blank_Space, DanielArmstrong, Davide, Draiakoo, Giorgio, McToady, MrPotatoMagic, PoeAudits, Ryonen, Silvermist, SpicyMeatball, Tychai0s, VAD37, Varun_05, alexxander, alexzoid, aslanbek, blutorque, btk, cats, d3e4, denzi_, evmboi32, fnanni, givn, grearlake, haxatron, jesjupyter, juancito, ke1caM, ktg, lanrebayode77, linmiaomiao, matejdb, merlinboii, n0kto, novamanbg, nuthan2x, petro_1912, pynschon, radin100, sashik_eth, shaka, sl1, soliditywala, solmaxis69, t0x1c, ubl4nk, vnavascues, xchen1130, yotov721, zhaojohnson
1.1225 USDC - $1.12
Element, weight, physicalAttributes may be created via wrong fighterType.
Function reRoll() will help users to recreate one fighter, change the fighter's element, weight, and physicalAttributes based on its fighterType. Function reRoll() cannot change the fighter's fighterType. So when users want to reRoll() his fighter, we will need check whether input fighterType is correct.
function reRoll(uint8 tokenId, uint8 fighterType) public { require(msg.sender == ownerOf(tokenId)); // need to check whether input fighterType is actual fighterType require(numRerolls[tokenId] < maxRerollsAllowed[fighterType]); require(_neuronInstance.balanceOf(msg.sender) >= rerollCost, "Not enough NRN for reroll"); _neuronInstance.approveSpender(msg.sender, rerollCost); bool success = _neuronInstance.transferFrom(msg.sender, treasuryAddress, rerollCost); if (success) { numRerolls[tokenId] += 1; uint256 dna = uint256(keccak256(abi.encode(msg.sender, tokenId, numRerolls[tokenId]))); (uint256 element, uint256 weight, uint256 newDna) = _createFighterBase(dna, fighterType); fighters[tokenId].element = element; fighters[tokenId].weight = weight; fighters[tokenId].physicalAttributes = _aiArenaHelperInstance.createPhysicalAttributes( newDna, generation[fighterType], fighters[tokenId].iconsType, fighters[tokenId].dendroidBool ); _tokenURIs[tokenId] = ""; } }
For example,
Manual
Considering reRoll() won't change fighterType. Add input check for figherType.
Invalid Validation
#0 - c4-pre-sort
2024-02-22T00:10:00Z
raymondfam marked the issue as sufficient quality report
#1 - c4-pre-sort
2024-02-22T00:10:17Z
raymondfam marked the issue as duplicate of #305
#2 - c4-pre-sort
2024-02-22T01:04:53Z
raymondfam marked the issue as duplicate of #306
#3 - c4-judge
2024-03-05T04:31:13Z
HickupHH3 marked the issue as satisfactory
#4 - c4-judge
2024-03-19T09:05:07Z
HickupHH3 changed the severity to 3 (High Risk)