code-423n4 / 2022-04-dualityfocus-findings

1 stars 0 forks source link

QA Report #30

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Summary

We list 1 low-critical finding and 3 non-critical findings here:

In conclusion, it's better to remove unused functions, remove duplicate definitions, and use defined modifiers when forking 3rd party contracts.

(Low) Lock pragma to ensure compiler version

Impact

Floating pragma may cause unexpected compilation time behaviour and introduce unintended bugs.

Proof of Concept

https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/vault_and_oracles/FlashLoan.sol#L1 https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/vault_and_oracles/MasterPriceOracle.sol#L2 https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/vault_and_oracles/UniV3LpVault.sol#L1 https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/vault_and_oracles/UniswapTwapOracle.sol#L1

Recommended Mitigation Steps

Don't use ^, lock pragma to ensure compiler version. e.g. pragma solidity 0.7.6;

(Non) Change the ownerOf requirement to isAuthorizedForToken modifier

Impact

isAuthorizedForToken modifier is already defined in UniV3LpVault.sol. It is better to unify the privilege checking method and not use require(ownerOf[tokenId] == msg.sender, …) directly in functions.

Proof of Concept

https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/vault_and_oracles/UniV3LpVault.sol#L102

Recommended Mitigation Steps

Change the ownerOf requirement to isAuthorizedForToken modifier.

(Non) _become and _becomeImplementation is unused

Impact

Duality removed upgradeability of Comptrollers, thus eliminating the need of Unitroller as proxy. Due to the modification, functions including Comptroller._become and Comptroller._becomeImplementation that are written to support upgradeability is no longer required, and should be removed.

Proof of Concept

https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/compound_rari_fork/Comptroller.sol#L1445-L1459

Recommended Mitigation Steps

Remove _become and _becomeImplementation functions.

(Non) Duplicate definition of uniV3LpVault

Impact

Comptroller inherits ComptrollerV3Storage and ComptrollerInterface, but both contracts have defined uniV3LpVault.

Proof of Concept

https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/compound_rari_fork/Comptroller.sol#L18 https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/compound_rari_fork/ComptrollerStorage.sol#L46 https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/compound_rari_fork/ComptrollerInterface.sol#L8

Recommended Mitigation Steps

Remove duplicate definition of uniV3LpVault.