Platform: Code4rena
Start Date: 23/11/2022
Pot Size: $24,500 CANTO
Total HM: 5
Participants: 37
Period: 5 days
Judge: berndartmueller
Total Solo HM: 2
Id: 185
League: ETH
Rank: 12/37
Findings: 2
Award: $73.58
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xSmartContract
Also found by: Deivitto, Josiah, RaymondFam, aphak5010, cccz, cryptonue, gzeon, joestakey, keccak123, martin, peritoflores, rotcivegaf
370.8153 CANTO - $59.89
The function withdraw()
is missing zero address check for _recipient
so it is possible to accidentally send ETH to zero address causing loss of funds
register()
and assign()
is actually a smart contractMaybe you could add a check to prevent EOA to call register or assign without being a smart contract.
As you are using already Oz you can perform this check in assign()
and register()
if (!isContract(msg.sender) revert CallerMustbeAContract();
#0 - c4-judge
2023-01-02T12:59:39Z
berndartmueller marked the issue as grade-b
🌟 Selected for report: Tricko
Also found by: 0xhacksmithh, AkshaySrivastav, Awesome, Beepidibop, Deivitto, DijkstraDev, Dinesh11G, Englave, JC, Rahoz, RaymondFam, ReyAdmirado, SaeedAlipoor01988, Sathish9098, abiih, aphak5010, chaduke, chrisdior4, exolorkistis, gzeon, martin, nicobevi, oyc_109, peritoflores, rotcivegaf
84.7394 CANTO - $13.69
External
modifier is cheaper than public
so considering using external for the following functions
function register(address _recipient) public onlyUnregistered returns (uint256 tokenId) { | function assign(uint256 _tokenId) public onlyUnregistered returns (uint256) { function withdraw(uint256 _tokenId, address payable _recipient, uint256 _amount) function distributeFees(uint256 _tokenId) public onlyOwner payable {
First of all, the function _mint
of OZ already checks that the address of recipient is different from zero so this checks is unnecessary . In addition, as I suggested in medium report, when you use _safeMint
this check will not be required either.
Maybe you prefer to keep code as it is for readability but accessing to msg.sender
will always be cheaper than using a local variable.
While reading msg.sender
will cost 2 gas every MSTORE and MREAD will cost 3 gas each
distributeFees
#0 - c4-judge
2022-11-29T19:37:52Z
berndartmueller marked the issue as grade-b