QA Report #314
Labels
bug
Something isn't working
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
valid
ISSUE LIST
C4-001 : Low level calls with solidity version 0.8.x can result in optimizer bug. - LOW
C4-002 : Centralization Risk - Low
C4-003 : Missing zero-address check in the setter functions in the constructor - Low
C4-004 : transferOwnership should be two step process - Low
C4-005 : Incompatibility With Rebasing/Deflationary/Inflationary tokens - LOW
C4-006 : Use of _msgSender() - Non - critical
C4-007 : Add disableInitializers to Prevent Front-running - LOW
C4-008 : Critical changes should use two-step procedure - Non Critical
C4-009 : External Upgradeable Contracts Are Not Initialized - Non critical
C4-001 : Low level calls with solidity version 0.8.x can result in optimizer bug.
Impact
The protocol is using low level calls with solidity version 0.8.x which can result in optimizer bug.
https://medium.com/certora/overly-optimistic-optimizer-certora-bug-disclosure-2101e3f7994d
Proof of Concept
Tools Used
Code Review
Recommended Mitigation Steps
Consider upgrading to solidity 0.8.15.
C4-002 : Centralization Risk
Impact - LOW
Owner role has absolute power across the contracts with several onlyOwner functions. There is no ability to change admin to a new address or renounce it which is helpful for lost/compromised admin keys or to delegate control to a different governance/DAO address in future.
The project does not use the widely used OpenZeppelin Ownable library which provides transfer/renounce functions to mitigate such compromised/accidental situations with admin keys. This makes admin role/key a single-point of failure.
Location
https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/HomeFi.sol#L123
Recommended Mitigation Steps
Ensure admins are reasonably redundant/independent (3/7 or 5/9) multisigs and add transfer/renounce functionality for admin. Consider using OpenZeppelin’s Ownable library.
C4-003 : Missing zero-address check in the setter functions in the constructor - Low
Impact
Missing checks for zero-addresses may lead to infunctional protocol, if the variable addresses are updated incorrectly.
Proof of Concept
Tools Used
Code Review
Recommended Mitigation Steps
Consider adding zero-address checks in the discussed constructors:
require(newAddr != address(0));.
C4-004 : # transferOwnership should be two step process
Impact
The contracts inherit OpenZeppelin's Ownable contract which enables the onlyOwner role to transfer ownership to another address. It's possible that the onlyOwner role mistakenly transfers ownership to the wrong address, resulting in a loss of the onlyOwner role. The current ownership transfer process involves the current owner calling Unlock.transferOwnership(). This function checks the new owner is not the zero address and proceeds to write the new owner's address into the owner's state variable. If the nominated EOA account is not a valid account, it is entirely possible the owner may accidentally transfer ownership to an uncontrolled account, breaking all functions with the onlyOwner() modifier. Lack of two-step procedure for critical operations leaves them error-prone
if the address is incorrect, the new address will take on the functionality of the new role immediately
for Ex : -Alice deploys a new version of the whitehack group address. When she invokes the whitehack group address setter to replace the address, she accidentally enters the wrong address. The new address now has access to the role immediately and is too late to revert
Proof of Concept
Tools Used
None
Recommended Mitigation Steps
Implement zero address check and Consider implementing a two step process where the owner nominates an account and the nominated account needs to call an acceptOwnership() function for the transfer of ownership to fully succeed. This ensures the nominated EOA account is a valid and active account.
C4-005 : Incompatibility With Rebasing/Deflationary/Inflationary tokens
Impact - LOW
Rigor protocol do not appear to support rebasing/deflationary/inflationary tokens whose balance changes during transfers or over time. The necessary checks include at least verifying the amount of tokens transferred to contracts before and after the actual transfer to infer any fees/interest.
Proof of Concept
Tools Used
Manual Code Review
Recommended Mitigation Steps
C4-006 : Use of msgSender
Impact - Non critical
Vulnerability details
Impact
The use of _msgSender() when there is no implementation of a meta transaction mechanism that uses it, such as EIP-2771, very slightly increases gas consumption.
Proof of Concept
_msgSender() is utilized three times where msg.sender could have been used in the following function.
Tools Used
None
Recommended Mitigation Steps
Replace _msgSender() with msg.sender if there is no mechanism to support meta-transactions like EIP-2771 implemented.
C4-007 : Add disableInitializers to Prevent Front-running
Code Location
https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Disputes.sol#L74
Impact
Defining initial values for variables when declaring them in a contract like in the code below does not work for upgradeable contracts.
Refer to explanation below:
https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#avoid-initial-values-in-field-declarations
Also, one should not leave the implementation contract uninitialized. None of the implementation contracts in the code base contains the code recommended by OpenZeppelin below, or an empty constructor with the initializer modifier.
Tools Used
Code Review
Recommended Mitigation Steps
Refer to the link below:
https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializing_the_implementation_contract
C4-008 : Critical changes should use two-step procedure
Impact - NON CRITICAL
The critical procedures should be two step process. The contracts inherit OpenZeppelin's Ownable contract which enables the onlyOwner role to transfer ownership to another address. It's possible that the onlyOwner role mistakenly transfers ownership to the wrong address, resulting in a loss of the onlyOwner role. The current ownership transfer process involves the current owner calling Unlock.transferOwnership(). This function checks the new owner is not the zero address and proceeds to write the new owner's address into the owner's state variable. If the nominated EOA account is not a valid account, it is entirely possible the owner may accidentally transfer ownership to an uncontrolled account, breaking all functions with the onlyOwner() modifier. Lack of two-step procedure for critical operations leaves them error-prone
if the address is incorrect, the new address will take on the functionality of the new role immediately
for Ex : -Alice deploys a new version of the whitehack group address. When she invokes the whitehack group address setter to replace the address, she accidentally enters the wrong address. The new address now has access to the role immediately and is too late to revert
Proof of Concept
Tools Used
Code Review
Recommended Mitigation Steps
Lack of two-step procedure for critical operations leaves them error-prone. Consider adding two step procedure on the critical functions.
C4-009 : External Upgradeable Contracts Are Not Initialized - Non critical
Vulnerability details
Impact
During the manual code review, It has been observed that re-entrancy guard contract is not initialized. The contract re-entrancy guard is not upgradeable. You need to - manually call the __{contract}_init(); method of every parent contract with appropriate parameters.
Proof of Concept
https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/HomeFi.sol#L29
Tools Used
Code Review
Recommended Mitigation Steps
Ensure that all necessary contracts are initialized from the upgradeable contracts. The sample can be seen from below.
The text was updated successfully, but these errors were encountered: