Platform: Code4rena
Start Date: 01/08/2023
Pot Size: $91,500 USDC
Total HM: 14
Participants: 80
Period: 6 days
Judge: gzeon
Total Solo HM: 6
Id: 269
League: ETH
Rank: 68/80
Findings: 1
Award: $15.35
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Team_FliBit
Also found by: 0x70C9, 3docSec, 8olidity, DavidGiladi, Krace, LokiThe5th, Rolezn, Sathish9098, UniversalCrypto, banpaleo5, catellatech, digitizeworx, fatherOfBlocks, hpsb, j4ld1na, josephdara, kutugu, niser93, nonseodion, oakcobalt, osmanozdemir1, pep7siup, ravikiranweb3, said, sivanesh_808
15.3494 USDC - $15.35
Report-1: Zero Address Check in Constructor of V3Proxy.sol
Introduction:
In the smart contract V3Proxy.sol
, a constructor is defined to initialize the contract with certain parameters. The constructor takes three parameters: _router
, _quoter
, and _fee
. This report focuses on the necessity of implementing a zero address check for these parameters in the constructor.
Description:
A crucial aspect of smart contract security is ensuring that inputs and parameters are properly validated to prevent unexpected behavior or vulnerabilities. The constructor provided in V3Proxy.sol
initializes the contract's internal state with the _router
, _quoter
, and _fee
parameters. However, it is important to ensure that these parameters are not set to the Ethereum zero address (0x0000000000000000000000000000000000000000).
The Ethereum zero address represents an invalid or unset address. Allowing the zero address as a parameter can lead to unexpected issues, vulnerabilities, or even loss of funds, as contracts might behave in unintended ways when interacting with invalid addresses.
Recommendation:
To enhance the security and robustness of the V3Proxy.sol
contract, it is strongly recommended to include a zero address check for the _router
, _quoter
, and _fee
parameters in the constructor. This check should ensure that none of these parameters are set to the Ethereum zero address before proceeding with the contract initialization.
Example Zero Address Check: Here is an example of how the zero address check can be implemented within the constructor:
constructor(ISwapRouter _router, IQuoter _quoter, uint24 _fee) { require(_router != ISwapRouter(address(0)), "Router address cannot be zero"); require(_quoter != IQuoter(address(0)), "Quoter address cannot be zero"); require(_fee > 0, "Fee should be greater than zero"); ROUTER = _router; QUOTER = _quoter; feeTier = _fee; }
Report-2: Missed-Hardcoded Address in TokenisableRange Contract
Description:
In the smart contract named TokenisableRange
, a hardcoded Ethereum address is utilized. The address is assigned to the public constant variable POS_MGR
and is directly defined within the contract code. The hardcoded address in question is 0xC36442b4a4522E871399CD717aBDD847Ab11FE88
, and it is assigned using the INonfungiblePositionManager
interface.
Address Hardcoded:
INonfungiblePositionManager constant public POS_MGR = INonfungiblePositionManager(0xC36442b4a4522E871399CD717aBDD847Ab11FE88);
Location of the Hardcoded Address:
You can find the hardcoded address in the TokenisableRange
contract at this specific line within the contract code.
This practice of hardcoding addresses can introduce risks and inflexibility into the contract, as changing the target address may necessitate a redeployment of the entire contract. It's generally recommended to store external contract addresses as state variables or provide them as constructor arguments, enabling more flexibility in case the address needs to be updated in the future without needing to redeploy the contract.
It's advised to consider modifying the contract to enhance its upgradeability and maintainability by avoiding hardcoded addresses and introducing more flexible methods for specifying contract dependencies.
Please note that this assessment is based on the code as of the provided link and may not reflect changes made after that point. It's recommended to review the contract and its codebase for any updates or changes that may have occurred since the provided link.
Report-3:Missing @Dev Emitted Event
Description:
In the contract ICreditDelegationToken.sol
, there is a missing @dev
comment for the emitted event BorrowAllowanceDelegated
. This event is declared as follows:
event BorrowAllowanceDelegated( address indexed fromUser, address indexed toUser, address asset, uint256 amount );
Link to the Code:
The declaration of the event can be found in the contract source code here.
Recommendation:
It is recommended to provide a descriptive @dev
comment for the BorrowAllowanceDelegated
event. This comment should explain the purpose and significance of the event, its parameters, and any relevant information for developers who might be interacting with the contract. Adding this comment will enhance the readability of the code and provide valuable context for anyone working with the contract.
Example:
Here's an example of how the missing @dev
comment could be added:
/** * @dev Emitted when the borrowing allowance is delegated from one user to another. * * This event indicates that the borrowing allowance for a specific asset has been transferred * from the `fromUser` to the `toUser` in the amount specified by `amount`. * * @param fromUser The address of the user delegating the borrowing allowance. * @param toUser The address of the user receiving the delegated borrowing allowance. * @param asset The address of the asset for which the borrowing allowance is being delegated. * @param amount The amount of borrowing allowance being delegated. */ event BorrowAllowanceDelegated( address indexed fromUser, address indexed toUser, address asset, uint256 amount );
Adding this kind of comment helps other developers understand the purpose and behavior of the event without having to dive into the event's implementation details.
Report-4: Pragma abi
It has come to our attention that the usage of pragma abicoder v2
might lead to compatibility issues when using Solidity version 0.7.5. This report aims to outline the specific instances where this incompatibility has been identified and provide more information about the affected contracts.
Description:
The pragma abicoder v2
directive is used to specify the default behavior of function parameter encoding and decoding in Solidity. It was introduced to improve the handling of function parameters and return values in more complex cases, particularly involving structs and arrays.
However, the usage of pragma abicoder v2
appears to be problematic when used with Solidity version 0.7.5. This pragma version might not be fully supported or compatible with the older compiler version, leading to potential compilation errors or unexpected behavior.
Affected Contracts:
The following contracts have been identified as utilizing pragma abicoder v2
and might face compatibility issues when used with Solidity 0.7.5:
IPoolInitializer.sol
ISwapRouter.sol
IAaveIncentivesController.sol
ILendingPoolConfigurator.sol
INonfungiblePositionManager.sol
IAaveLendingPoolV2.sol
Recommendation:
To mitigate these compatibility issues, it is recommended to consider the following steps:
Upgrade Compiler Version: Consider upgrading the Solidity compiler version to a more recent one that better supports pragma abicoder v2
, or use a version that is known to work well with this pragma version.
Check Documentation: Consult the official Solidity documentation and release notes to understand the compatibility matrix between pragma abicoder v2
and various compiler versions. This can help in making informed decisions regarding the compiler version to be used.
Code Review and Testing: Thoroughly review and test the contracts that utilize pragma abicoder v2
with the specific compiler version you intend to use. Identify and address any compilation errors or unexpected behavior that might arise due to the pragma version.
Consider Alternative Solutions: If compatibility issues persist, consider revisiting the usage of pragma abicoder v2
and evaluate whether alternative approaches or workarounds can achieve the desired functionality without encountering compatibility problems.
It's important to stay updated with the latest advancements in the Solidity ecosystem and ensure that the chosen compiler version and pragmas are well-supported to maintain the reliability and security of your smart contracts.
Report-5: Unused EVENT
This report identifies and documents instances of unused events in the codebase of the "GoodEntry" project. Unused events can bloat the code and increase complexity, so it's important to clean them up for better code maintainability and readability.
Here are the identified instances of unused events along with their descriptions and corresponding links to the code:
Event: event Transfer(address indexed from, address indexed to, uint256 value);
Description: This is a standard ERC-20 event for token transfers. It's declared in IERC20.sol but not used within the project.
Event: event Approval(address indexed owner, address indexed spender, uint256 value);
Description: Another standard ERC-20 event for approval of token spending. It's declared in IERC20.sol but remains unused in the codebase.
Event: event Approval(address indexed owner, address indexed spender, uint256 value);
Description: Similar to the above, this event is also declared in IAToken.sol, but it's unused within the project.
Event: event Mint();
Description: This event is declared in IInitializableAToken.sol but not utilized within the codebase.
Event: event Flash(....);
Description: This event is declared in IUniswapV3Factory.sol but not used within the project.
Event: event PoolCreated(address indexed token0, address indexed token1, ...);
Description: This event is declared in IUniswapV3Factory.sol, but its declaration remains unused.
Event: event AddressUpdated(string indexed name, address indexed newAddress);
Description: This event is declared in ILendingPoolAddressesProvider.sol, but it's not used within the codebase.
Event: event MintOnDeposit(address indexed _to, uint256 _amount);
Description: This event is declared in IAToken.sol but remains unused within the project.
Event: event Redeem(address indexed _from, address indexed _to, ...);
Description: This event is declared in IAToken.sol but is not utilized within the codebase.
Event: event Transfer(address indexed sender, address indexed recipient, ...);
Description: This event is declared in IUniswapV2Pair.sol, but its declaration is unused.
Event: event Mint(address to, uint256 tokenId, ...);
Description: This event is declared in IUniswapV2Pair.sol, but it's not utilized within the codebase.
Event: event Claimed(...);
Description: This event is declared in IAaveIncentivesController.sol, but its declaration remains unused.
Event: event LendingPoolConfiguratorUpdated(...);
Description: This event is declared in ILendingPoolConfigurator.sol, but it's not used within the codebase.
Event: event Transfer(uint256 indexed tokenId, address indexed from, ...);
Description: This event is declared in INonfungiblePositionManager.sol, but its declaration is unused.
These unused event declarations should be reviewed and potentially removed from the codebase to enhance code clarity and maintainability.
#0 - 141345
2023-08-10T10:01:07Z
#1 - c4-judge
2023-08-20T16:36:02Z
gzeon-c4 marked the issue as grade-b