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: 88/243
Findings: 1
Award: $27.69
š Selected for report: 0
š Solo Findings: 0
š Selected for report: MrPotatoMagic
Also found by: 3th, Fulum, JohnnyTime, K42, Kose, SAAJ, Toshii, catellatech, cats, clara, digitizeworx, dimulski, dy, glcanvas, hunter_w3b, ihtishamsudo, niki, peanuts
27.6948 USDC - $27.69
This analysis report is a general overview of my auditing process how I understand this codebase and how I tackle this code finding vulnerabilities. This report will provide detailed understanding of codebase and the things developers are unaware of.
I have used the following approach for auditing the codebase:
NextGenCore
core to provide random hash that make every NFT collection unique based on unique random hash.The contract structure to be honest can be improved a lot. All the libraries, interfaces, core & helper contracts are in the same folder. It was in asymetrical manner and wasn't in a proper structure. I have suggested the following structure to the team:
contracts āāā core ā āāā NextGenCore.sol ā āāā MinterContract.sol ā āāā NextGenAdmins.sol ā āāā AuctionDemo.sol āāā Randomizers ā āāā RandomizerNXT.sol ā āāā RandomizerRNG.sol ā āāā RandomizerVRF.sol | |āā XRandoms.sol āāā Interfaces ā āāā IMinterContract.sol ā āāā INextGenAdmins.sol ā āāā INextGenCore.sol ā āāā IRandomizer.sol ā āāā IXRandoms.sol āāā Libraries ā āāā OZ contracts
coming to the codebase, main structre of code wasn't upto the mark really like when I was reading the core contract, The code itself isn't following the standard structure for writing solidity contract. There was mappings, structs, events, modifiers, in arbitrary form in up and down manner no really sequence. Same with all the main contracts.
I find one thing very intriguing about this codebase and that was using admin control in a very weird way. I think team did a pretty job in handling the codebase with strict access but fails to handle access control at some things which i submitted in my Findings. So, most of the things are in admins hand and it's pretty interesting that NextGenTeam is trying to control most of the things in their way.
I find one thing that i looked at and audited again and again that was randomizer, Yes I'm not very familiar with RNG Randiomizer but audited many codebases that have Chainlink VRF and that was the interesting thing to look up at again.
Codebase was using ownable access control of OZ that was very familiar and find some decent things in the implementation.
There wasn't proper documentation in the whole codebase. Actual codebase documentation was very poor, you can say there was only hint about the functions and logics in the contracts that what this specific function does. If someone has to depend on code documentation then it's very hard to understand the codebase. I would have suggested the team to write proper documentation of the codebase not in the gitbook but also in the codebase comments.
To be honest, codebase wasn't really ready for the audit like there are basic things that can be imporved based on the development side. Like codebase comments can be imporved, functions can be refactored, structure can be imporved. There are so many minor bugs that real bugs might be hidden because codebase wasn't in its best form. NXT Team should consider doing proper testing and imporiving codebase before going for audit.
Logics were kept very straight and simple. I didn't find any complex logics in the codebase. Even though by skimming through the codebase it was looking like that the codebase is very rough and will have a lot of things to disclose but team did it well in handling the logics but overall codebase quality wasn't upto the mark as discuss in the above section.
Overall code base quality = 50%
Codebase testing was very poor. Only tests were written in hardhat and we can only write unit tests in hardhat. There was no fuzzing testing or invariant testing to check if the edge cases are still holding up or not. So, Team should consider writing tests in foundry and do proper fuzzing and invariant testing. I would suggest team to do following steps to imporve codebase quality.
Proper Fuzzing With Echidna Or Foundry
Proper Invariant Testing With FOundry
Unit Testing Of Each & Every Function in Foundry
Codebase was very strict in access control. Most of the functions were either control by admins of NextGen Team. Even if the artist have to set collection info he himself can't do it only admin or global admin can do it so that makes it very centralized.
Most of the codebase is handled by admins that are decalred in NextGenAdmins.sol
and those admins are are set by NextGen Team and those admins are moslty handling the stuff.
So, I consider this a very centralised codebase.
There is a sneaky function called emergencyWithdraw()
i want to disclose and how I consider this as a rug pull that it is in the way that all the funds can be transferred to the admins contract means the team can tranfer the funds into their contract.
Just have a look at this function :
function emergencyWithdraw() public FunctionAdminRequired(this.emergencyWithdraw.selector) { uint balance = address(this).balance; address admin = adminsContract.owner(); (bool success, ) = payable(admin).call{value: balance}(""); emit Withdraw(msg.sender, success, balance); }
This function is in the Minter Contract which mint all the tokens and collections in this codebase. Obviously we can't mint for free and certainly when minting takes place money is coming in this contract an here's NextGen team played a thing they made a the above function that in case of emergency they will call the this function and fun fact is that it is only callable by only admins means NextGen Team. By executing this function they are transferring funds to admins contract.
There was a discusion that admins and teams are trusted so there shouldn't be issue about admins or NXT team by there was a lot of rug pull cases where admins rug pull their loyal users for the sake of money. In this case i won't the admins will be ever trusted in this case because if it was like that so there would be no rug pull cases in the history of crypto. So, I consider this a rug pull scenario, and it should be mitigated.
I have consumed the following resources in this audit:
Day 1-2 : Understanding Codebase Day 3-4 : Finding weakspots, tagging things with audit tags Day 4-6 : Finding Vulnerabilities Day 6-8 : Preparing Reports For submission Day 8-10: Submitting Vulnerabilties, QA Report & Analysis Report
Total Time Spent in Hours : 80 Hours
78 hours
#0 - c4-pre-sort
2023-11-27T14:58:16Z
141345 marked the issue as sufficient quality report
#1 - c4-judge
2023-12-07T16:52:13Z
alex-ppg marked the issue as grade-b