trailofbits / manticore

Symbolic execution tool
https://blog.trailofbits.com/2017/04/27/manticore-symbolic-execution-for-humans/
GNU Affero General Public License v3.0
3.7k stars 472 forks source link

manticore.exceptions.EthereumError: Error deserializing type (uint256,string,uint8,string) #1382

Open YannickXiong opened 5 years ago

YannickXiong commented 5 years ago

OS / Environment

macOS mojave 10.14.1

Manticore version

Version: 0.2.4

Python version

python 3.6

Dependencies

Summary of the problem

myContract.sol has multiple contracts. using manticore --contract myContractName ./myContract.sol leads to error as fellow.

manticore.exceptions.EthereumError: Error  deserializing type (uint256,string,uint8,string)

Step to reproduce the behavior

Expected behavior

Actual behavior

Any relevant logs

manticore --contract myContractName ./myContract.sol
2019-03-06 09:06:23,455: [2658] m.c.manticore:INFO: Verbosity set to 1.
2019-03-06 09:06:23,515: [2658] m.main:INFO: Registered plugins: DetectIntegerOverflow, DetectDelegatecall, DetectReentrancySimple, DetectExternalCallAndLeak, DetectUninitializedMemory, DetectUninitializedStorage, DetectReentrancyAdvanced, DetectUnusedRetVal, DetectSuicidal, DetectEnvInstruction, DetectInvalid
2019-03-06 09:06:23,515: [2658] m.main:INFO: Beginning analysis
2019-03-06 09:06:23,517: [2658] m.e.manticore:INFO: Starting symbolic create contract
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/ethereum/abi.py", line 209, in deserialize
    result = ABI._deserialize(abitypes.parse(ty), data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/ethereum/abi.py", line 236, in _deserialize
    result += (ABI._deserialize(ty_i, buf, offset), )
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/ethereum/abi.py", line 231, in _deserialize
    result = buf[dyn_offset + 32:dyn_offset + 32 + size]
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/core/smtlib/expression.py", line 927, in __getitem__
    size = self._get_size(index)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/core/smtlib/expression.py", line 582, in _get_size
    assert isinstance(size, BitVecConstant)
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/bin/manticore", line 11, in <module>
    load_entry_point('manticore==0.2.4', 'console_scripts', 'manticore')()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/__main__.py", line 41, in main
    ethereum_main(args, logger)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/ethereum/cli.py", line 68, in ethereum_main
    tx_account=args.txaccount, tx_preconstrain=args.txpreconstrain)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/ethereum/manticore.py", line 978, in multi_tx_analysis
    args=args, working_dir=working_dir)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/ethereum/manticore.py", line 615, in solidity_create_contract
    args = self.make_symbolic_arguments(constructor_types)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/ethereum/manticore.py", line 570, in make_symbolic_arguments
    return ABI.deserialize(types, self.make_symbolic_buffer(32, name='INITARGS', avoid_collisions=True))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/manticore/ethereum/abi.py", line 212, in deserialize
    raise EthereumError("Error {} deserializing type {:s}".format(str(e), type_spec))
manticore.exceptions.EthereumError: Error  deserializing type (uint256,string,uint8,string)
disconnect3d commented 5 years ago

@feliam can you look at this?

feliam commented 5 years ago

I can confirm this is an issue. make_symbolic_arguments() should make a better effort to produce reasonable symblic variabes for the given types. ref. https://github.com/trailofbits/manticore/blob/c113a13a27833597dd7336d7eee867d0225dd56d/manticore/ethereum/manticore.py#L568-L573

YannickXiong commented 5 years ago

@feliam Thanks, bro. By the way, what's the temporary trouble shooting?