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

5 stars 0 forks source link

QA Report #58

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Low

1. Outdated compiler

The pragma version used are:

pragma solidity 0.8.13;

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

Examples:

2. Undesired approval deletion

getApproved is deleted when someone transfer a token to himself. By not changing ownership of the token, it is not intended or expected to change approvals.

Affected source code:

3. 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:

4. Use encode instead of encodePacked for hashig

Use of abi.encodePacked in PuttyV2 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:

5. Use of money laundering

It is possible to use the contract as a money launderer since it will be the contract that sends the money from possibly illicit activities to a third account.

Example:

Affected source code:

6. Use npm packages instead of copy the dependencies

Some contracts use the openzeppelin libraries, as it should be, however these libraries are copied throughout the project instead of use the package manager.

Using the packages from the original developer helps us stay up-to-date when new bugs appear.

Affected source code:

7. Override all balanceOf logic

The contract PuttyV2Nft is abstract and remove the balanceOf logic in all method except the _burn one.

Although it is not an issue a priori, if the burn logic is changed to not transfer the token to 0xdead address, it could cause unnecessary errors.

Reference:

// send the long position to 0xdead. instead of doing a standard burn by sending to 0x000...000, sending to 0xdead ensures that the same position id cannot be minted again.

It's recommended to override the method _burn like this:

function _burn(uint256 id) internal override {
    address owner = _ownerOf[id];
    require(owner != address(0), "NOT_MINTED");
    delete _ownerOf[id];
    delete getApproved[id];
    emit Transfer(owner, address(0), id);
}

Affected source code:

outdoteth commented 2 years ago
  1. Outdated compiler

Duplicate: Use of solidity 0.8.13 with known issues in ABI encoding and memory side effects: https://github.com/code-423n4/2022-06-putty-findings/issues/348