Coinsult

Request your audit at coinsult.net

Advanced Manual
Smart Contract Audit

May 7, 2022

Audit requested by

Criba Inu (Router)

0x31d21Ec3722Cf628380b330ca01fc71A5F5e4c65

Criba Inu (Router) / Security Audit

Table of Contents

1. Audit Summary

1.1 Audit scope

1.2 Tokenomics

1.3 Source Code

2. Disclaimer

3. Global Overview

3.1 Informational issues

3.2 Low-risk issues

3.3 Medium-risk issues

3.4 High-risk issues

4. Vulnerabilities Findings

5. Contract Privileges

5.1 Maximum Fee Limit Check

5.2 Contract Pausability Check

5.3 Max Transaction Amount Check

5.4 Exclude From Fees Check

5.5 Ability to Mint Check

5.6 Ability to Blacklist Check

5.7 Owner Privileges Check

6. Notes

6.1 Notes by Coinsult

6.2 Notes by Criba Inu (Router)

7. Contract Snapshot

8. Website Review

9. Certificate of Proof

Criba Inu (Router) / Security Audit

Audit Summary

Audit Scope

Project Name

Criba Inu (Router)

Blockchain

Binance Smart Chain

Smart Contract Language

Solidity

Contract Address

0x31d21Ec3722Cf628380b330ca01fc71A5F5e4c65

Audit Method

Static Analysis, Manual Review

Date of Audit

7 May 2022

This audit report has been prepared by Coinsult’s experts at the request of the client. In this audit, the results of the static analysis and the manual code review will be presented. The purpose of the audit is to see if the functions work as intended, and to identify potential security issues within the smart contract.

The information in this report should be used to understand the risks associated with the smart contract. This report can be used as a guide for the development team on how the contract could possibly be improved by remediating the issues that were identified.

Criba Inu (Router) / Security Audit

Tokenomics

Source Code

Coinsult was comissioned by Criba Inu (Router) to perform an audit based on the following code:
https://cronoscan.com/address/0x31d21ec3722cf628380b330ca01fc71a5f5e4c65#code

Contract is setup as a router

Criba Inu (Router) / Security Audit

Disclaimer

This audit report has been prepared by Coinsult’s experts at the request of the client. In this audit, the results of the static analysis and the manual code review will be presented. The purpose of the audit is to see if the functions work as intended, and to identify potential security issues within the smart contract.

The information in this report should be used to understand the risks associated with the smart contract. This report can be used as a guide for the development team on how the contract could possibly be improved by remediating the issues that were identified.

Coinsult is not responsible if a project turns out to be a scam, rug-pull or honeypot. We only provide a detailed analysis for your own research.

Coinsult is not responsible for any financial losses. Nothing in this contract audit is financial advice, please do your own research.

The information provided in this audit is for informational purposes only and should not be considered investment advice. Coinsult does not endorse, recommend, support or suggest to invest in any project. 

Coinsult can not be held responsible for when a project turns out to be a rug-pull, honeypot or scam.

Criba Inu (Router) / Security Audit

Global Overview

Manual Code Review

In this audit report we will highlight the following issues:

Vulnerability Level

Total

Pending

Acknowledged

Resolved

0

0

0

0

5

0

0

0

0

0

0

0

0

0

0

0

Criba Inu (Router) / Security Audit

Avoid relying on block.timestamp

block.timestamp can be manipulated by miners.

				
					    modifier ensure(uint deadline) {
        require(deadline >= block.timestamp, 'RouterV2: EXPIRED');
        _;
    }


				
			

Recommendation

Do not use block.timestampnow or blockhash as a source of randomness

Exploit scenario

				
					contract Game {

    uint reward_determining_number;

    function guessing() external{
      reward_determining_number = uint256(block.blockhash(10000)) % 10;
    }
}
				
			

Eve is a miner. Eve calls guessing and re-orders the block containing the transaction. As a result, Eve wins the game.

Criba Inu (Router) / Security Audit

Missing events arithmetic

Detect missing events for critical arithmetic parameters.

				
					    {
        require(path[0] == WETH, 'RouterV2: INVALID_PATH');
        uint amountIn = msg.value;
        IWETH(WETH).deposit{value: amountIn}();
        assert(IWETH(WETH).transfer(MainLibrary.pairFor(factory, path[0], path[1]), amountIn));
        uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
        _swapSupportingFeeOnTransferTokens(path, to);
        require(
            IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
            'RouterV2: INSUFFICIENT_OUTPUT_AMOUNT'
        );
    }
				
			

Recommendation

Emit an event for critical parameter changes.

Exploit scenario

				
					contract C {

  modifier onlyAdmin {
    if (msg.sender != owner) throw;
    _;
  }

  function updateOwner(address newOwner) onlyAdmin external {
    owner = newOwner;
  }
}
				
			

updateOwner() has no event, so it is difficult to track off-chain changes in the buy price.

Criba Inu (Router) / Security Audit

Conformance to Solidity naming conventions

Allow _ at the beginning of the mixed_case match for private variables and unused parameters.

				
					IWETH(WETH).withdraw(amountETH);
				
			

Recommendation

Follow the Solidity naming convention.

Rule exceptions

  • Allow constant variable name/symbol/decimals to be lowercase (ERC20).
  • Allow _ at the beginning of the mixed_case match for private variables and unused parameters.

Criba Inu (Router) / Security Audit

Redundant Statements

Detect the usage of redundant statements that have no effect.

				
					 // refund dust eth, if any
if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);

(remove comments)
				
			

Recommendation

Remove redundant statements if they congest code but offer no value.

Exploit scenario

				
					contract RedundantStatementsContract {

    constructor() public {
        uint; // Elementary Type Name
        bool; // Elementary Type Name
        RedundantStatementsContract; // Identifier
    }

    function test() public returns (uint) {
        uint; // Elementary Type Name
        assert; // Identifier
        test; // Identifier
        return 777;
    }
}
				
			

Each commented line references types/identifiers, but performs no action with them, so no code will be generated for such statements and they can be removed.

Criba Inu (Router) / Security Audit

Costly operations inside a loop

Costly operations inside a loop might waste gas, so optimizations are justified. 

				
					    function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
        for (uint i; i < path.length - 1; i++) {
            (address input, address output) = (path[i], path[i + 1]);
            (address token0,) = MainLibrary.sortTokens(input, output);
            uint amountOut = amounts[i + 1];
            (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
            address to = i < path.length - 2 ? MainLibrary.pairFor(factory, output, path[i + 2]) : _to;
            IUniswapV2Pair(MainLibrary.pairFor(factory, input, output)).swap(
                amount0Out, amount1Out, to, new bytes(0)
            );
        }
    }
				
			

Recommendation

Use a local variable to hold the loop computation result.

Exploit scenario

				
					contract CostlyOperationsInLoop{

    function bad() external{
        for (uint i=0; i < loop_count; i++){
            state_variable++;
        }
    }

    function good() external{
      uint local_variable = state_variable;
      for (uint i=0; i < loop_count; i++){
        local_variable++;
      }
      state_variable = local_variable;
    }
}
				
			

Incrementing state_variable in a loop incurs a lot of gas because of expensive SSTOREs, which might lead to an out-of-gas.

Criba Inu (Router) / Security Audit

Other Owner Privileges Check

Coinsult lists all important contract methods which the owner can interact with.

  • No real owner privileges

Criba Inu (Router) / Security Audit

Notes

Notes by Criba Inu (Router)

No notes provided by the team.

Notes by Coinsult

✅ No notes provided by Coinsult

Criba Inu (Router) / Security Audit

Contract Snapshot

This is how the constructor of the contract looked at the time of auditing the smart contract.

				
					contract RouterV2 is IUniswapV2Router02 {
    using SafeMath for uint;

    address public immutable override factory;
    address public immutable override WETH;

    modifier ensure(uint deadline) {
        require(deadline &gt;= block.timestamp, 'RouterV2: EXPIRED');
        _;
    }

    constructor(address _factory, address _WETH) {
        factory = _factory;
        WETH = _WETH;
    }

    receive() external payable {
        assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
    }

    // **** ADD LIQUIDITY ****
    function _addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin
				
			

Criba Inu (Router) / Security Audit

Website Review

Coinsult checks the website completely manually and looks for visual, technical and textual errors. We also look at the security, speed and accessibility of the website. In short, a complete check to see if the website meets the current standard of the web development industry. 

Type of check

Description

Mobile friendly?

Contains jQuery errors?

Is SSL secured?

Contains spelling errors?

Criba Inu (Router) / Security Audit

Certificate of Proof

Criba Inu (Router)

Audited by Coinsult.net

Date: 7 May 2022

Coinsult

coinsult.net

End of report
Smart Contract Audit

Request your smart contract audit / KYC

t.me/coinsult_tg