Consensys / mythril

Security analysis tool for EVM bytecode. Supports smart contracts built for Ethereum, Hedera, Quorum, Vechain, Rootstock, Tron and other EVM-compatible blockchains.
https://mythx.io/
MIT License
3.78k stars 726 forks source link

Mythril analyze returning AttributeError #1813

Open basedwdev opened 9 months ago

basedwdev commented 9 months ago

Description

mythril.interfaces.cli [ERROR]: Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/mythril/interfaces/cli.py", line 966, in parse_args_and_execute
    address = load_code(disassembler, args)
  File "/usr/local/lib/python3.10/site-packages/mythril/interfaces/cli.py", line 717, in load_code
    address, _ = disassembler.load_from_solidity(
  File "/usr/local/lib/python3.10/site-packages/mythril/mythril/mythril_disassembler.py", line 291, in load_from_solidity
    for contract in get_contracts_from_file(
  File "/usr/local/lib/python3.10/site-packages/mythril/solidity/soliditycontract.py", line 132, in get_contracts_from_file
    yield SolidityContract(
  File "/usr/local/lib/python3.10/site-packages/mythril/solidity/soliditycontract.py", line 197, in __init__
    ).extract_features()
  File "/usr/local/lib/python3.10/site-packages/mythril/solidity/features.py", line 28, in extract_features
    ether_vars = self.extract_address_variable(node)
  File "/usr/local/lib/python3.10/site-packages/mythril/solidity/features.py", line 224, in extract_address_variable
    transfer_vars.update(self.extract_address_variable(value))
  File "/usr/local/lib/python3.10/site-packages/mythril/solidity/features.py", line 228, in extract_address_variable
    transfer_vars.update(self.extract_address_variable(item))
  File "/usr/local/lib/python3.10/site-packages/mythril/solidity/features.py", line 228, in extract_address_variable
    transfer_vars.update(self.extract_address_variable(item))
  File "/usr/local/lib/python3.10/site-packages/mythril/solidity/features.py", line 210, in extract_address_variable
    node.get("nodeType", "") == "ExpressionStatement"
AttributeError: 'NoneType' object has no attribute 'get'

How to Reproduce

myth analyze myContract.sol

-> contract code can be found https://bscscan.com/token/0xadb58e26d623acc31870318e419d86fb36c3d9c3#code

using macbook m1 with OS venture 13.4.1

Expected behavior

Should return SWC codes

Screenshots

N/A

Environment

macbook m1 with OS venture 13.4.1

Please modify for your setup

pip3 show mythril Name: mythril Version: 0.24.0 Summary: Security analysis tool for Ethereum smart contracts Home-page: https://github.com/ConsenSys/mythril Author: ConsenSys Dilligence Author-email: License: MIT Location: /opt/homebrew/lib/python3.11/site-packages Requires: asn1crypto, blake2b-py, certifi, coincurve, coloredlogs, configparser, coverage, cytoolz, eth-abi, eth-account, eth-hash, eth-keyfile, eth-rlp, eth-utils, ethereum-input-decoder, hexbytes, jinja2, MarkupSafe, matplotlib, mock, mypy-extensions, numpy, persistent, pre-commit, py-ecc, py-evm, py-flags, py-solc, py-solc-x, pyparsing, pytest, pytest-cov, pytest-mock, requests, rlp, scikit-learn, semantic-version, transaction, z3-solver Required-by:

solc --version solc, the solidity compiler commandline interface Version: 0.8.21+commit.d9974bed.Darwin.appleclang

python3 --version Python 3.11.6

OS venture 13.4.1

Additional Environment or Context

N/A

norhh commented 9 months ago

Hi, This should be fixed in the develop -> new 0.24.1 version Although for some reason the constructor is not being run properly

norhh commented 9 months ago

The constructor not being run properly is likely due to IUniswapV2Router02 being an interface over a contract, so solidity compiler lacks any information on the code and directly relies on onchain code which is not possible locally with mythril without connecting to a chain, if you paste the contract over IUniswapV2Router02, it shouldn't revert during construction