Canto Identity Subprotocols contest - lukris02's results

Subprotocols for Canto Identity Protocol.

General Information

Platform: Code4rena

Start Date: 17/03/2023

Pot Size: $36,500 USDC

Total HM: 10

Participants: 98

Period: 3 days

Judge: leastwood

Total Solo HM: 5

Id: 223

League: ETH

Canto Identity Subprotocols

Findings Distribution

Researcher Performance

Rank: 45/98

Findings: 2

Award: $34.80

QA:
grade-b
Gas:
grade-b

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Awards

22.7749 USDC - $22.77

Labels

bug
grade-b
QA (Quality Assurance)
edited-by-warden
Q-10

External Links

QA Report for Canto Identity Subprotocols contest

Overview

During the audit, 8 low and 9 non-critical issues were found.

β„–TitleRisk RatingInstance Count
L-1Docs may mislead usersLow1
L-2Return the amount available for mintingLow1
L-3Add comment about _safeMintLow2
L-4Use the two-step-transfer of ownershipLow2
L-5Critical Address Changes Should Use Two-step ProcedureLow4
L-6Use Checks Effects Interactions patternLow1
L-7Malicious token contracts can pass the ownership checkLow2
L-8Might need to change mint() function in ProfilePicture.solLow1
NC-1Use gender-neutral pronounsNon-Critical2
NC-2Validate tray priceNon-Critical1
NC-3Order of FunctionsNon-Critical4
NC-4Order of LayoutNon-Critical3
NC-5Missing NatSpecNon-Critical2
NC-6Commented codeNon-Critical1
NC-7Inconsistency when using uint and uint256Non-Critical5
NC-8Maximum line length exceededNon-Critical9
NC-9Missing leading underscoresNon-Critical13

Low Risk Findings(8)

L-1. Docs may mislead users

Description

Docs says: "A fusing fee that is proportial to the length of the name is charged". Although it seems obvious that a shorter name is more unique and therefore more expensive. Reading the protocol documentation, the user may think that the longer the name, the higher the price and, therefore, they may choose a shorter name and pay more.

Instances
Recommendation

Change to "A fusing fee that is inversely proportional to the length of the name is charged" or "A fusing fee that is proportional to the length of the name is charged. The shorter the name, the higher the fee".

L-2. Return the amount available for minting

Description

For convenience, the amount available for minting should be returned in the error message.

Instances
Recommendation

Change to:

if (startingTrayId + _amount - 1 > PRE_LAUNCH_MINT_CAP) revert MintExceedsPreLaunchAmount(PRE_LAUNCH_MINT_CAP - startingTrayId - 1);

L-3. Add comment about _safeMint

Description

If the comment in the Tray.sol is also valid for ProfilePicture.sol, then duplicate the comment in the ProfilePicture.sol. Otherwise, _safeMint can be used.

Instances

L-4. Use the two-step-transfer of ownership

Description

"{Owned} from "solmate/auth/Owned.sol" has one-step transfer of ownership. If the owner accidentally transfers ownership to an incorrect address, protected functions may become permanently inaccessible.

Instances
Recommendation

Consider using a two-step-transfer of ownership: the current owner would nominate a new owner, and to become the new owner, the nominated account would have to approve the change, so that the address is proven to be valid.

L-5. Critical Address Changes Should Use Two-step Procedure

Description

Lack of two-step procedure for critical operations leaves them error-prone.

Instances
Recommendation

Consider adding two step procedure on the critical functions.

L-6. Use Checks Effects Interactions pattern

Description

For reducing the attack surface for malicious contracts trying to hijack control flow after an external call, it is best practice to use this pattern.

Instances
uint256 tokenId = ++numMinted; if (ERC721(_nftContract).ownerOf(_nftID) != msg.sender) revert PFPNotOwnedByCaller(msg.sender, _nftContract, _nftID);
Recommendation

Change to:

if (ERC721(_nftContract).ownerOf(_nftID) != msg.sender) revert PFPNotOwnedByCaller(msg.sender, _nftContract, _nftID); uint256 tokenId = ++numMinted;

L-7. Malicious token contracts can pass the ownership check

Description

Verification that the user owns NFT can be passed using malicious token contracts, this can negatively affect the operation of the protocol.

Instances

L-8. Might need to change mint() function in ProfilePicture.sol

Description

The user may mint many PFP NFT with the same reference _nftContract and _nftID.

Instances
Recommendation

If it is not intended that the user can mint multiple PFP NFTs using the same reference NFT, then it is necessary to keep track of which NFTs the user has already used.

Non-Critical Risk Findings(9)

NC-1. Use gender-neutral pronouns

Instances
Recommendation

Change to:

  • Any user can mint a Bio NFT by calling Bio.mint and passing their biography.
  • A user can therefore precompute which trays they will get.

NC-2. Validate tray price

Description

Price validation can be added.

Instances
Recommendation

Consider setting a minimum and maximum allowable price per tray and check if the function parameter matches it.

NC-3. Order of Functions

Description

According to Style Guide, ordering helps readers identify which functions they can call and to find the constructor and fallback definitions easier.
Functions should be grouped according to their visibility and ordered:

  1. constructor
  2. receive function (if exists)
  3. fallback function (if exists)
  4. external
  5. public
  6. internal
  7. private
Instances
Recommendation

Public functions should be placed after external.

NC-4. Order of Layout

Description

According to Order of Layout, inside each contract, library or interface, use the following order:

  1. Type declarations
  2. State variables
  3. Events
  4. Modifiers
  5. Functions
Instances
Recommendation

Place structs before state variables.

NC-5. Missing NatSpec

Description

NatSpec is missing for 2 functions in 1 contract.

Instances
Recommendation

Add NatSpec for all functions.

NC-6. Commented code

Instances
Recommendation

Delete commented code.

NC-7. Inconsistency when using uint and uint256

Description

Some variables is declared as uint and some as uint256. Below 5 instances when uint is used, while uint256 is used in all other 110 instances.

Instances
Recommendation

Stick to one style.

NC-8. Maximum line length exceeded

Description

According to Style Guide, maximum suggested line length is 120 characters. Longer lines make the code harder to read.

Instances
Recommendation

Make the lines shorter.

NC-9. Missing leading underscores

Description

Private constants, immutables, and state variables should have a leading underscore.

Instances
Recommendation

Add leading underscores where needed.

#0 - c4-judge

2023-04-11T05:49:59Z

0xleastwood marked the issue as grade-b

Gas Optimizations Report for Canto Identity Subprotocols contest

Overview

During the audit, 1 gas issue were found.
Total savings ~560.

β„–TitleInstance CountSaved
G-1Use unchecked blocks for subtractions where underflow is impossible16560

Gas Optimizations Findings(1)

G-1. Use unchecked blocks for subtractions where underflow is impossible

Description

In Solidity 0.8+, there’s a default overflow and underflow check on unsigned integers. When an overflow or underflow isn’t possible (after require or if-statement), some gas can be saved by using unchecked blocks.

Instances
Saved

This saves ~35.
So, ~35*16 = 560

#0 - c4-judge

2023-04-10T23:55:31Z

0xleastwood marked the issue as grade-b

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