Platform: Code4rena
Start Date: 30/10/2023
Pot Size: $49,250 USDC
Total HM: 14
Participants: 243
Period: 14 days
Judge: 0xsomeone
Id: 302
League: ETH
Rank: 114/243
Findings: 2
Award: $13.39
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: smiling_heretic
Also found by: 00decree, 00xSEV, 0x180db, 0x3b, 0x656c68616a, 0xAadi, 0xAleko, 0xAsen, 0xDetermination, 0xJuda, 0xMAKEOUTHILL, 0xMango, 0xMosh, 0xSwahili, 0x_6a70, 0xarno, 0xgrbr, 0xpiken, 0xsagetony, 3th, 8olidity, ABA, AerialRaider, Al-Qa-qa, Arabadzhiev, AvantGard, CaeraDenoir, ChrisTina, DanielArmstrong, DarkTower, DeFiHackLabs, Deft_TT, Delvir0, Draiakoo, Eigenvectors, Fulum, Greed, HChang26, Haipls, Hama, Inference, Jiamin, JohnnyTime, Jorgect, Juntao, Kaysoft, Kose, Kow, Krace, MaNcHaSsS, Madalad, MrPotatoMagic, Neon2835, NoamYakov, Norah, Oxsadeeq, PENGUN, REKCAH, Ruhum, Shubham, Silvermist, Soul22, SovaSlava, SpicyMeatball, Talfao, TermoHash, The_Kakers, Toshii, TuringConsulting, Udsen, VAD37, Vagner, Zac, Zach_166, ZdravkoHr, _eperezok, ak1, aldarion, alexfilippov314, alexxander, amaechieth, aslanbek, ast3ros, audityourcontracts, ayden, bdmcbri, bird-flu, blutorque, bronze_pickaxe, btk, c0pp3rscr3w3r, c3phas, cartlex_, cccz, ciphermarco, circlelooper, crunch, cryptothemex, cu5t0mpeo, darksnow, degensec, dethera, devival, dimulski, droptpackets, epistkr, evmboi32, fibonacci, gumgumzum, immeas, innertia, inzinko, jasonxiale, joesan, ke1caM, kimchi, lanrebayode77, lsaudit, mahyar, max10afternoon, merlin, mrudenko, nuthan2x, oakcobalt, openwide, orion, phoenixV110, pontifex, r0ck3tz, rotcivegaf, rvierdiiev, seeques, shenwilly, sl1, slvDev, t0x1c, tallo, tnquanghuy0512, tpiliposian, trachev, twcctop, vangrim, volodya, xAriextz, xeros, xuwinnie, y4y, yobiz, zhaojie
0 USDC - $0.00
The impact of this finding is that the AuctionDemo.sol
contract could be susceptible to bid manipulation, potentially allowing a bidder to win an auction with a lower bid than initially placed. This issue could undermine the fairness and integrity of the auction system.
The initial lower bidder could win the auction with an exceptionally lower bid, which may not represent the true value of the item being auctioned. This could lead to unfair outcomes and manipulation of the auction results.
Here is the vulnerable code segment in the AuctionDemo contract:
function cancelBid(uint256 _tokenid, uint256 index) public { require(block.timestamp <= minter.getAuctionEndTime(_tokenid), "Auction ended"); require(auctionInfoData[_tokenid][index].bidder == msg.sender && auctionInfoData[_tokenid][index].status == true); auctionInfoData[_tokenid][index].status = false; (bool success, ) = payable(auctionInfoData[_tokenid][index].bidder).call{value: auctionInfoData[_tokenid][index].bid}(""); emit CancelBid(msg.sender, _tokenid, index, success, auctionInfoData[_tokenid][index].bid); }
Attack Scenario:
Manual review.
Consider implementing one or more of the following mitigation steps:
Other
#0 - c4-pre-sort
2023-11-15T09:16:38Z
141345 marked the issue as duplicate of #962
#1 - c4-judge
2023-12-02T15:13:10Z
alex-ppg marked the issue as not a duplicate
#2 - c4-judge
2023-12-02T15:16:44Z
alex-ppg marked the issue as duplicate of #1784
#3 - c4-judge
2023-12-07T11:49:41Z
alex-ppg marked the issue as duplicate of #1323
#4 - c4-judge
2023-12-08T17:26:43Z
alex-ppg marked the issue as partial-50
#5 - c4-judge
2023-12-08T17:28:18Z
alex-ppg marked the issue as satisfactory
#6 - c4-judge
2023-12-08T18:18:56Z
alex-ppg marked the issue as partial-50
🌟 Selected for report: The_Kakers
Also found by: 00xSEV, 0x3b, Arabadzhiev, DeFiHackLabs, Fulum, Madalad, MrPotatoMagic, SpicyMeatball, Tadev, ZanyBonzy, ZdravkoHr, alexfilippov314, audityourcontracts, cheatc0d3, devival, dy, evmboi32, immeas, lsaudit, mrudenko, oakcobalt, oualidpro, pipidu83, r0ck3tz, rishabh, rotcivegaf, tpiliposian, xAriextz
13.3948 USDC - $13.39
The XRandoms.sol
contract is used to generate random word from a given 100-length words array. But the function getWord()
returns this:
if (id==0) { return wordsList[id]; } else { return wordsList[id - 1]; }
This function is called from randomWord()
function which can generate a random number from 0 to 99. This means that in case a random number is 0 or 1, it will take the first word from the array, and there is no chance of having a last word from the array.
Delete else
block from the getWord()
function, or generate a random number from 0 to 100:
-- if (id==0) { return wordsList[id]; -- } else { -- return wordsList[id - 1]; -- }
-- uint256 randomNum = uint(keccak256(abi.encodePacked(block.prevrandao, blockhash(block.number - 1), block.timestamp))) % 100; ++ uint256 randomNum = uint(keccak256(abi.encodePacked(block.prevrandao, blockhash(block.number - 1), block.timestamp))) % 101;
In the XRandoms.sol
contract the function returnIndex()
is used to return an index for a given parameter id
but there are no checks if the id
is not greater than 99 or 100 (depending on the fix to the previous Wrong random number generator
issue).
function returnIndex(uint256 id) public view returns (string memory) { return getWord(id); }
Add missing checks for the id
parameter, as written in the descriptions.
In the RandomizerRNG.sol
and RandomizerVRF.sol
contracts, the updateCoreContract
function is used to update the _gencore
parameter. However, this function does not include a check to ensure that the provided _gencore
address is not the zero address (address(0)). Allowing the zero address as a valid parameter can lead to unexpected behavior and potential vulnerabilities.
function updateCoreContract(address _gencore) public FunctionAdminRequired(this.updateCoreContract.selector) { gencore = _gencore; gencoreContract = INextGenCore(_gencore); }
In the RandomizerNXT.sol
there are missing checks in the following functions:
function updateRandomsContract(address _randoms) public FunctionAdminRequired(this.updateRandomsContract.selector) { randoms = IXRandoms(_randoms); } function updateAdminsContract(address _admin) public FunctionAdminRequired(this.updateAdminsContract.selector) { adminsContract = INextGenAdmins(_admin); } function updateCoreContract(address _gencore) public FunctionAdminRequired(this.updateCoreContract.selector) { gencore = _gencore; gencoreContract = INextGenCore(_gencore); }
A zero address check should be added at the beginning of the given functions.
In the RandomizerRNG.sol
contract, the updateRNGCost
function is used to update the ethRequired
parameter without any bounds or limits. This means that anyone with the appropriate permissions can set the ethRequired
value to any arbitrary number, which could potentially lead to unintended behavior or economic vulnerabilities.
function updateRNGCost(uint256 _ethRequired) public FunctionAdminRequired(this.updateRNGCost.selector) { ethRequired = _ethRequired; }
Add appropriate limits or constraints on the values that can be set for the ethRequired
parameter within the updateRNGCost
function. These limits should be defined based on the requirements and constraints of the contract.
The artistSignature
function in the NextGenCore.sol
contract allows an artist to submit their signature for a collection. However, there is no validation mechanism to prevent or correct mistakes if the _signature
input is set to an undesired value, such as 0. This could lead to incorrect or unintended signatures for a collection, and once a signature is set, there is no way to update it.
function artistSignature(uint256 _collectionID, string memory _signature) public { require(msg.sender == collectionAdditionalData[_collectionID].collectionArtistAddress, "Only artist"); require(artistSigned[_collectionID] == false, "Already Signed"); artistsSignatures[_collectionID] = _signature; artistSigned[_collectionID] = true; }
Add an empty _signature
check in the given function.
#0 - 141345
2023-11-25T08:16:27Z
449 tpiliposian l r nc 1 1 0
L 1 d dup of https://github.com/code-423n4/2023-10-nextgen-findings/issues/508 L 2 l L 3 i L 4 i L 5 r
#1 - c4-pre-sort
2023-11-25T08:20:33Z
141345 marked the issue as sufficient quality report
#2 - alex-ppg
2023-12-08T15:32:56Z
The Warden's QA report has been graded B based on a score of 20 combined with a manual review per the relevant QA guideline document located here.
The Warden's submission's score was assessed based on the following accepted findings:
#3 - c4-judge
2023-12-08T15:33:02Z
alex-ppg marked the issue as grade-b