Canto Identity Subprotocols contest - Bauchibred'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: 65/98

Findings: 1

Award: $22.77

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

22.7749 USDC - $22.77

Labels

bug
grade-b
QA (Quality Assurance)
Q-41

External Links

Canto Identity Subprotocols QA Report

Low Issues

L-01 Incomplete input parameter validation

Impact

The Tray.getTile() function would always return 0 when _tileOffset>=7 but users might not know why

Proof of concept

The Tray..getTile() function provides information about one tile and it takes in two parameters uint256 _trayId and uint8 _tileOffset), the function does include a check for when the _trayId is non existent, L196 of Tray.sol: if (!_exists(_trayId)) revert TrayNotMinted(_trayId); But there are no checks to confirm that _tileOffset < 7, and its explicitly stated that _tileOffset needs to be between 0 .. TILES_PER_TRAY - 1 in the param natspec of _tileOffset at L194: /// @param _tileOffset Offset of the tile within the query, needs to be between 0 .. TILES_PER_TRAY - 1 meaning that when a user calls this function with an invalid tile offset they get a wrong return value and might not understand what the issue is.

Create an additional error case: error InvalidTileOffset(uint8 _tileOffset) Add a conditiion to Tray.getTile() that _tileOffset must be between 0 .. TILES_PER_TRAY - 1 function getTile(uint256 _trayId, uint8 _tileOffset) external view returns (TileData memory tileData) { if (!_exists(_trayId)) revert TrayNotMinted(_trayId); if(_tileOffset >= 7) revert InvalidTileOffset(uint8 _tileOffset) tileData = tiles[_trayId][_tileOffset]; }

L-02 Changing note and/or revenue addresses to the zero address should be avoided.

Impact

If both or either of note and revenue addresses gets set to the zero address, any call to these contracts while being set to 0 is going to lead to unexpected behaviour such as contract reverts and force redeployments

Proof of concept

There are no zero address checks in the functions Namepsace.changeNoteAddress() and Namepsace.changeRevenueAddress() function changeNoteAddress(address _newNoteAddress) external onlyOwner { address currentNoteAddress = address(note); note = ERC20(_newNoteAddress); emit NoteAddressUpdate(currentNoteAddress, _newNoteAddress); }

function changeRevenueAddress(address _newRevenueAddress) external onlyOwner { address currentRevenueAddress = revenueAddress; revenueAddress = _newRevenueAddress; emit RevenueAddressUpdated(currentRevenueAddress, _newRevenueAddress); }

Zero address checks should be added

Non-Critical Issues

NC-01 Not completely accurate error name in the Namespace.fuse() function

Impact

Users might not understand why their transaction is reverting

Proof of concept

The revert error InvalidNumberOfCharacters() is only used once in Namespace.sol at L112 if (numCharacters > 13 || numCharacters == 0) revert InvalidNumberOfCharacters(numCharacters); As evident it's used to revert the case when the number of characters are more than 13, but the name of the error suggests otherwise and might lead users to not really understand why their transaction is reverting.

Change error name from InvalidNumberOfCharacters(uint256 numCharacters) to NumberOfCharactersTooLong(uint256 numCharacters)

NC-02 Simplify code

Impact

Simplified code can help users/developers understand and use code easier.

Proof of concept

Utils.sol L179-181 Includes script and also comments before these lines indicate that the 3 characters come from a different UTF-8 block, and therefore the values got hardcoded, but for all three cases the value returned are the same and as such all three conditions can be combined into one with the help of the OR operator.

Change the below: if (_characterIndex == 4) return hex"F09D9192"; if (_characterIndex == 6) return hex"F09D9194"; if (_characterIndex == 14) return hex"F09D919C";

to: if (_characterIndex == 4 || _characterIndex == 6 || _characterIndex == 14) ) return hex"F09D9192";

#0 - c4-judge

2023-04-11T16:20:03Z

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