Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mythril analyze returning AttributeError #1813

Open
basedwdev opened this issue Oct 22, 2023 · 2 comments
Open

Mythril analyze returning AttributeError #1813

basedwdev opened this issue Oct 22, 2023 · 2 comments

Comments

@basedwdev
Copy link

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

  • Mythril version: output from myth version or pip show mythril

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:

  • Solidity compiler and version: solc --version

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

  • Python version: python -V

python3 --version
Python 3.11.6

  • OS and Version: [e.g. Mac OS High Sierra]

OS venture 13.4.1

Additional Environment or Context

N/A

@norhh
Copy link
Collaborator

norhh commented Oct 23, 2023

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
Copy link
Collaborator

norhh commented Oct 23, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants