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.67k stars 471 forks source link

Error: unsupported operand type(s) for pow(): 'int', 'BitVecConstant', 'int' #2391

Open 0M1N0U5 opened 3 years ago

0M1N0U5 commented 3 years ago

OS / ENVIRONMENT

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal

Summary of the problem

While analyzing a contract the application threw the error "unsupported operand type(s) for pow(): 'int', 'BitVecConstant', 'int'". The full trace is shown at the end.

Manticore version

Version: 0.3.5

Python version

$ python -V -> Python 2.7.18 $ python3 -V -> Python 3.8.5

Dependencies

apsw==3.28.0.post1 apturl==0.5.2 attrs==20.3.0 base58==2.1.0 bcrypt==3.1.7 beautifulsoup4==4.8.2 bitarray==1.2.2 blinker==1.4 Brlapi==0.7.0 capstone==4.0.1 certifi==2019.11.28 chardet==3.0.4 Click==7.0 colorama==0.4.3 command-not-found==0.3 compile==1.0.3 cryptography==2.8 crytic-compile==0.1.12 css-parser==1.0.4 cssselect==1.1.0 cssutils==1.0.2 cupshelpers==1.0 cytoolz==0.11.0 dbus-python==1.2.16 defer==1.0.6 distro==1.4.0 distro-info===0.23ubuntu1 dnspython==1.16.0 duplicity==0.8.12.0 entrypoints==0.3 eth-abi==2.1.1 eth-account==0.5.4 eth-hash==0.3.1 eth-keyfile==0.5.1 eth-keys==0.3.3 eth-rlp==0.2.1 eth-typing==2.2.2 eth-utils==1.10.0 fasteners==0.14.1 feedparser==5.2.1 future==0.18.2 hexbytes==0.2.1 html2text==2020.1.16 html5-parser==0.4.9 html5lib==1.0.1 httplib2==0.14.0 idna==2.8 ifaddr==0.1.6 ipfshttpclient==0.7.0a1 jsonschema==3.2.0 keyring==18.0.1 KismetCaptureFreaklabsZigbee==2018.7.0 KismetCaptureRtl433==2019.9.1 KismetCaptureRtladsb==2019.10.1 KismetCaptureRtlamr==2019.10.1 language-selector==0.1 launchpadlib==1.10.13 lazr.restfulclient==0.14.2 lazr.uri==1.0.3 lockfile==0.12.2 louis==3.12.0 lru-dict==1.1.7 lxml==4.5.0 macaroonbakery==1.3.1 Mako==1.1.0

Editable install with no version control (manticore==0.3.5)

-e /home/user/.local/lib/python3.8/site-packages Markdown==3.1.1 MarkupSafe==1.1.0 mechanize==0.4.5 Mentalist==1.0 monotonic==1.5 msgpack==0.6.2 multiaddr==0.0.9 netaddr==0.8.0 netifaces==0.10.4 nose==1.3.7 oauthlib==3.1.0 olefile==0.46 packaging==20.3 paramiko==2.6.0 parsimonious==0.8.1 pexpect==4.6.0 Pillow==7.0.0 ply==3.11 prettytable==2.0.0 protobuf==3.14.0 pycairo==1.16.2 pychm==0.8.6 pycryptodome==3.10.1 pycups==1.9.73 pyelftools==0.27 pyevmasm==0.2.3 Pygments==2.3.1 PyGObject==3.36.0 PyJWT==1.7.1 pymacaroons==0.13.0 PyNaCl==1.3.0 pyparsing==2.4.6 PyQt5==5.14.1 PyQtWebEngine==5.14.0 pyRFC3339==1.1 pyrsistent==0.17.3 pysha3==1.0.2 python-apt==2.0.0+ubuntu0.20.4.4 python-dateutil==2.7.3 python-debian===0.1.36ubuntu1 pytz==2019.3 pyxdg==0.26 PyYAML==5.3.1 regex==2019.8.19 reportlab==3.5.34 repoze.lru==0.7 requests==2.22.0 requests-unixsocket==0.2.0 rlp==2.0.1 Routes==2.4.1 screen-resolution-extra==0.0.0 SecretStorage==2.3.1 simplejson==3.16.0 sip==4.19.21 six==1.14.0 solc-select==0.2.0 soupsieve==1.9.5 systemd-python==234 toolz==0.11.1 ubuntu-advantage-tools==20.3 ubuntu-drivers-common==0.0.0 ufw==0.36 unattended-upgrades==0.1 unicorn==1.0.2rc2 urllib3==1.25.8 usb-creator==0.3.7 varint==1.0.2 vboxapi==1.0 wadllib==1.3.3 wasm==1.2 wcwidth==0.2.5 web3==5.16.0 webencodings==0.5.1 WebOb==1.8.5 websockets==8.1 xkit==0.0.0 z3-solver==4.8.10.0 zeroconf==0.24.4

LOG

2021-02-18 21:32:08,793: [12876] m.c.worker:ERROR: Exception in state 3: TypeError("unsupported operand type(s) for pow(): 'int', 'BitVecConstant', 'int'") Traceback (most recent call last): File "/home/user/.local/lib/python3.8/site-packages/manticore/core/worker.py", line 121, in run current_state.execute() File "/home/user/.local/lib/python3.8/site-packages/manticore/ethereum/state.py", line 8, in execute return self._platform.execute() File "/home/user/.local/lib/python3.8/site-packages/manticore/platforms/evm.py", line 3093, in execute self.current_vm.execute() File "/home/user/.local/lib/python3.8/site-packages/manticore/platforms/evm.py", line 1313, in execute result = self._handler(arguments) File "/home/user/.local/lib/python3.8/site-packages/manticore/platforms/evm.py", line 1179, in _handler return implementation(arguments) File "/home/user/.local/lib/python3.8/site-packages/manticore/platforms/evm.py", line 622, in wrapper return func(*args, **kwargs) File "/home/user/.local/lib/python3.8/site-packages/manticore/platforms/evm.py", line 1555, in EXP return pow(base, exponent, TT256) TypeError: unsupported operand type(s) for pow(): 'int', 'BitVecConstant', 'int'

feliam commented 3 years ago

Try:

    def EXP(self, base, exponent)
            result = 1
            for i in range(256):
                result = Operators.ITEBV(256, exponent & 1 == 1, base * result, result)
                base = base * base
                exponent = exponent >> 1
            return result
0M1N0U5 commented 3 years ago

Try:

    def EXP(self, base, exponent)
            result = 1
            for i in range(256):
                result = Operators.ITEBV(256, exponent & 1 == 1, base * result, result)
                base = base * base
                exponent = exponent >> 1
            return result

Firstly thank your response.

I tested your code by modifying the env.py file. The error is gone but now I get back a "Killed" message and manticore terminates without more information.

Console log:

2021-02-19 17:19:29,972: [31106] m.main:INFO: Beginning analysis 2021-02-19 17:19:29,975: [31106] m.e.manticore:INFO: Starting symbolic create contract 2021-02-19 17:54:52,182: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 128) 2021-02-19 17:54:52,316: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 129) 2021-02-19 17:54:52,454: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 130) 2021-02-19 17:54:52,585: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 131) 2021-02-19 17:54:52,716: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 132) 2021-02-19 17:54:52,842: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 133) 2021-02-19 17:54:52,972: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 134) 2021-02-19 17:54:53,109: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 135) 2021-02-19 17:54:53,237: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 136) 2021-02-19 17:54:53,371: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 137) 2021-02-19 17:54:53,506: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 138) 2021-02-19 17:54:53,635: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 139) 2021-02-19 17:54:53,763: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 140) 2021-02-19 17:54:53,895: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 141) 2021-02-19 17:54:54,028: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 142) 2021-02-19 17:54:54,157: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 143) 2021-02-19 17:54:54,293: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 144) 2021-02-19 17:54:54,431: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 145) 2021-02-19 17:54:54,567: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 146) 2021-02-19 17:54:54,714: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 147) 2021-02-19 17:54:54,844: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 148) 2021-02-19 17:54:54,978: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 149) 2021-02-19 17:54:55,118: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 150) 2021-02-19 17:54:55,253: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 151) 2021-02-19 17:54:55,392: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 152) 2021-02-19 17:54:55,527: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 153) 2021-02-19 17:54:55,675: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 154) 2021-02-19 17:54:55,806: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 155) 2021-02-19 17:54:55,944: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 156) 2021-02-19 17:54:56,080: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 157) 2021-02-19 17:54:56,288: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 158) 2021-02-19 17:54:56,425: [31106] m.e.detectors:WARNING: Potentially reading uninitialized memory at instruction (address: 1377213805960731181178752887404202209569922156671, offset 159) Killed

enderphan94 commented 3 years ago

Did you fix this issue? I got the same problem