code-423n4 / 2022-06-nibbl-findings

1 stars 0 forks source link

QA Report #34

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Low

Obsolete pragma

The pragma version used is:

pragma solidity 0.8.10;
pragma solidity ^0.8.0;

But recently solidity released a new version with important Bugfixes:

Apart from these, there are several minor bug fixes and improvements.

The minimum required version should be 0.8.14

Lack of empty address checks

The following methods have a lack checks if the received argument is an address, it's good practice in order to reduce human error to check that the address specified in the constructor or initialize is different than address(0).

address(0):

AccessControl / Pausable

The contract NibblVaultFactory is AccessControl and Pausable, so the owner could resign while the contract is paused, causing a Denial of Service. Owner resignation while paused should be avoided.

Affected source code:

Use encode instead of encodePacked for hashig

Use of abi.encodePacked in NibblVaultFactory is safe, but unnecessary and not recommended. abi.encodePacked can result in hash collisions when used with two dynamic arguments (string/bytes).

There is also discussion of removing abi.encodePacked from future versions of Solidity (ethereum/solidity#11593), so using abi.encode now will ensure compatibility in the future.

Affected source code:

Unsafe ERC20 calls

The following code doesn't check the result of the ERC20 calls. ERC20 standard specify that the token can return false if these calls fails, so it's mandatory to check the result of these ERC20 methods.

Reference:

NOTES: The following specifications use syntax from Solidity 0.4.17 (or above) Callers MUST handle false from returns (bool success). Callers MUST NOT assume that false is never returned!

Affected source code for transfer:

Lack of ACK during owner change

It's possible to lose the ownership under specific circumstances.

Because an human error it's possible to set a new invalid owner. When you want to change the owner's address it's better to propose a new owner, and then accept this ownership with the new wallet.

Affected source code:

Non critical

Outdated packages

The packages used are out of date, it is good practice to use the latest version of these packages:

"@openzeppelin/contracts": "^4.5.0",
"@openzeppelin/contracts-upgradeable": "^4.5.0",

Affected source code:

Use call to transfer ether

Because to transfer ether the .transfer method (which is capped at 2300 gas) is used instead of .call which is limited to the gas provided by the user. If a contract that has a fallback method more expensive than 2300 gas, it will be impossible for a contract receive funds from Basket contract.

Reference:

Affected source code:

Use interval for update window

If a maximum of time is not used during the update proposal, it is possible that the update will be made at the beginning or during deploy it, and after a few years, the change will be accepted, and users won't be aware of that. It is convenient to use a maximum expiration time of the proposal.

Affected source code:

Possible loss of token 0

Token 0 is more or less the owner of the Basket contract. If this token is transfered to the wrong address, for example address(this), this ownership could be losed.

It would be convenient to block the transfer when the token is 0 and to is address(this) (address(0) it's already checked.).

Affected source code:

Use abstract for base contracts

Abstract contracts are contracts that have at least one function without its implementation. An instance of an abstract cannot be created.

Reference:

Affected source code:

Wrong initialization

Wrong token name is used during the initialization of NibblVault.INIT_EIP712. NibblVault is used instead of _tokenName.

Affected source code:

Lack of lock in sell method

if buy have lock, sell should have it, because the danger is the same.

Affected source code:

HardlyDifficult commented 2 years ago

Merging with https://github.com/code-423n4/2022-06-nibbl-findings/issues/35

HardlyDifficult commented 2 years ago

Merging with https://github.com/code-423n4/2022-06-nibbl-findings/issues/37

HardlyDifficult commented 2 years ago

Merging with https://github.com/code-423n4/2022-06-nibbl-findings/issues/38

HardlyDifficult commented 2 years ago

Very good feedback. Recommendations are clear & specific to the Nibbl contracts.