Description
I use two conditional expressions to execute & bit arithmetic operation. But failed in length check.
│ /home/squ/Projects/self-proj/Warden/src/see/engine.py:382 in exec_branch │
│ │
│ 379 │ │ │ elif op == const.opcode.AND: │
│ 380 │ │ │ │ [s0, s1] = state.stack_pop(2) │
│ 381 │ │ │ │ # fix for python10 claripy │
│ ❱ 382 │ │ │ │ state.stack_push(s0 & s1) │
│ 383 │ │ │ │ # state.stack_push( │
│ 384 │ │ │ │ # claripy.If( │
│ 385 │ │ │ │ # claripy.And((s0 != BVV0), (s1 != BVV0)), │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ bps = [] │ │
│ │ curinst = <Instruction name=AND address=0x6ea size=1 > │ │
│ │ depth = 3 │ │
│ │ op = 22 │ │
│ │ pushnum = 32 │ │
│ │ s0 = <BV256 if input-uint256_2_256 != 0x0 then 0x1 else 0x0> │ │
│ │ s1 = <BV256 if 0x2 > 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff │ │
│ │ / input-uint256_2_256 then 0x1 else 0x0> │ │
│ │ self = <see.engine.SymExecEngine object at 0x7fb09f40ea70> │ │
│ │ state = State( │ │
│ │ selfdestruct_to = None │ │
│ │ pc = 6ea │ │
│ │ calls = [] │ │
│ │ storage = 1 <BV256 (0xff & LShR(LShR(LShR(input-uint256_3_256, 0x8), 0x8), 0x8)) * │ │
│ │ 0x1 | 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00 & (0x100 │ │
│ │ * (0x0 .. input-uint256_3_256[23:16]) | (0x10000 * (0x0 .. │ │
│ │ input-uint256_3_256[15:8])[255:16] | (0x1000000 * (0x0 .. │ │
│ │ input-uint256_3_256[7:0])[255:24] .. 0) .. 0x0))> │ │
│ │ │ │
│ │ solver = <claripy.solvers.Solver object at 0x7fb09ef79e40> │ │
│ │ ) │ │
│ │ txn = <evm.transaction.Transaction object at 0x7fb09ef7aaa0> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/squ/.local/lib/python3.10/site-packages/claripy/operations.py:57 in _op │
│ │
│ 54 │ │ │ │ │ raise ClaripyOperationError(msg) │
│ 55 │ │ │
│ 56 │ │ # pylint:disable=too-many-nested-blocks │
│ ❱ 57 │ │ simp = _handle_annotations(simplifications.simpleton.simplify(name, fixed_args), │
│ 58 │ │ if simp is not None: │
│ 59 │ │ │ return simp │
│ 60 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _type_fixer = <function op.<locals>._type_fixer at 0x7fb0a53765f0> │ │
│ │ args = ( │ │
│ │ │ <BV256 if input-uint256_2_256 != 0x0 then 0x1 else 0x0>, │ │
│ │ │ <BV256 if 0x2 > │ │
│ │ 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff / │ │
│ │ input-uint256_2_256 then 0x1 else 0x0> │ │
│ │ ) │ │
│ │ calc_length = <function basic_length_calc at 0x7fb0a559ff40> │ │
│ │ extra_check = <function length_same_check at 0x7fb0a559feb0> │ │
│ │ fixed_args = ( │ │
│ │ │ <BV256 if input-uint256_2_256 != 0x0 then 0x1 else 0x0>, │ │
│ │ │ <BV256 if 0x2 > │ │
│ │ 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff / │ │
│ │ input-uint256_2_256 then 0x1 else 0x0> │ │
│ │ ) │ │
│ │ i = <BV256 if 0x2 > │ │
│ │ 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff / │ │
│ │ input-uint256_2_256 then 0x1 else 0x0> │ │
│ │ msg = "args' length must all be equal" │ │
│ │ name = '__and__' │ │
│ │ return_type = <class 'claripy.ast.bv.BV'> │ │
│ │ success = True │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/squ/.local/lib/python3.10/site-packages/claripy/simplifications.py:43 in simplify │
│ │
│ 40 │ def simplify(self, op, args): │
│ 41 │ │ if op not in self._simplifiers: │
│ 42 │ │ │ return None │
│ ❱ 43 │ │ return self._simplifiers[op](*args) │
│ 44 │ │
│ 45 │ @staticmethod │
│ 46 │ def _deduplicate_filter(args): │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ args = ( │ │
│ │ │ <BV256 if input-uint256_2_256 != 0x0 then 0x1 else 0x0>, │ │
│ │ │ <BV256 if 0x2 > │ │
│ │ 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff / │ │
│ │ input-uint256_2_256 then 0x1 else 0x0> │ │
│ │ ) │ │
│ │ op = '__and__' │ │
│ │ self = <claripy.simplifications.SimplificationManager object at 0x7fb0a55dc5b0> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/squ/.local/lib/python3.10/site-packages/claripy/simplifications.py:734 in │
│ bitwise_and_simplifier │
│ │
│ 731 │ │ │ # if(cond0, 1, 0) & if(cond1, 1, 0) -> if(cond0 & cond1, 1, 0) │
│ 732 │ │ │ if a.op == "If" and b.op == "If": │
│ 733 │ │ │ │ if ( │
│ ❱ 734 │ │ │ │ │ (a.args[1] == ast.all_operations.BVV(1, 1)).is_true() │
│ 735 │ │ │ │ │ and (a.args[2] == ast.all_operations.BVV(0, 1)).is_true() │
│ 736 │ │ │ │ │ and (b.args[1] == ast.all_operations.BVV(1, 1)).is_true() │
│ 737 │ │ │ │ │ and (b.args[2] == ast.all_operations.BVV(0, 1)).is_true() │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ a = <BV256 if input-uint256_2_256 != 0x0 then 0x1 else 0x0> │ │
│ │ args = () │ │
│ │ b = <BV256 if 0x2 > 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff / │ │
│ │ input-uint256_2_256 then 0x1 else 0x0> │ │
│ │ r = None │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/squ/.local/lib/python3.10/site-packages/claripy/operations.py:54 in _op │
│ │
│ 51 │ │ │ if extra_check is not None: │
│ 52 │ │ │ │ success, msg = extra_check(*fixed_args) │
│ 53 │ │ │ │ if not success: │
│ ❱ 54 │ │ │ │ │ raise ClaripyOperationError(msg) │
│ 55 │ │ │
│ 56 │ │ # pylint:disable=too-many-nested-blocks │
│ 57 │ │ simp = _handle_annotations(simplifications.simpleton.simplify(name, fixed_args), │
│ │
│ ╭────────────────────────────── locals ──────────────────────────────╮ │
│ │ _type_fixer = <function op.<locals>._type_fixer at 0x7fb0a5375360> │ │
│ │ args = (<BV256 0x1>, <BV1 1>) │ │
│ │ calc_length = None │ │
│ │ extra_check = <function length_same_check at 0x7fb0a559feb0> │ │
│ │ fixed_args = (<BV256 0x1>, <BV1 1>) │ │
│ │ i = <BV1 1> │ │
│ │ msg = "args' length must all be equal" │ │
│ │ name = '__eq__' │ │
│ │ return_type = <class 'claripy.ast.bool.Bool'> │ │
│ │ success = False │ │
│ ╰────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
Steps to reproduce the bug
a = BVS("uint256-a", 256)
b = BVS("uint256-b", 256)
BVV0 = BVV(0, 256)
BVV1 = BVV(1, 256)
solver = Solver()
# solver.add(Not(a == 0))
c = If(a > 0, BVV(0xff, 256), BVV0)
d = If(b < 0xff, BVV(0xff, 256), BVV0)
e = (c ^ d)
print(e) # work
e = (c | d)
print(e) # work
e = (c & d)
print(e) # !!! raise ClaripyOperationError(claripy.errors.ClaripyOperationError: args' length must all be equal)
Environment
angr environment report
Date: 2023-12-25 19:30:05.904681
!!! running in global environment. Are you sure? !!!
Platform: linux-x86_64
Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
######## angr #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/angr/init.py
Pip version angr 9.2.81
Couldn't find git info
######## ailment #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/ailment/init.py
Pip version ailment 9.2.81
Couldn't find git info
######## cle #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/cle/init.py
Pip version cle 9.2.81
Couldn't find git info
######## pyvex #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/pyvex/init.py
Pip version pyvex 9.2.81
Couldn't find git info
######## claripy #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/claripy/init.py
Pip version claripy 9.2.81
Couldn't find git info
######## archinfo #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/archinfo/init.py
Pip version archinfo 9.2.81
Couldn't find git info
######## z3 #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/z3/init.py
Pip version z3-solver 4.10.2.0
Couldn't find git info
######## unicorn #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/unicorn/init.py
Pip version unicorn 2.0.1.post1
Couldn't find git info
######### Native Module Info ##########
angr: <CDLL '/home/squ/.local/lib/python3.10/site-packages/angr/state_plugins/../lib/angr_native.so', handle 55c215f60590 at 0x7f463e041d80>
unicorn: <CDLL '/home/squ/.local/lib/python3.10/site-packages/unicorn/lib/libunicorn.so.2', handle 55c215a70b20 at 0x7f4640d21630>
pyvex: <cffi.api._make_ffi_library..FFILibrary object at 0x7f4641a1e320>
z3: <CDLL '/home/squ/.local/lib/python3.10/site-packages/z3/lib/libz3.so', handle 55c215737340 at 0x7f4643bfb7c0>
Additional context
No response
Description
I use two conditional expressions to execute
&bit arithmetic operation. But failed in length check.Steps to reproduce the bug
Environment
angr environment report
Date: 2023-12-25 19:30:05.904681
!!! running in global environment. Are you sure? !!!
Platform: linux-x86_64
Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
######## angr #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/angr/init.py
Pip version angr 9.2.81
Couldn't find git info
######## ailment #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/ailment/init.py
Pip version ailment 9.2.81
Couldn't find git info
######## cle #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/cle/init.py
Pip version cle 9.2.81
Couldn't find git info
######## pyvex #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/pyvex/init.py
Pip version pyvex 9.2.81
Couldn't find git info
######## claripy #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/claripy/init.py
Pip version claripy 9.2.81
Couldn't find git info
######## archinfo #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/archinfo/init.py
Pip version archinfo 9.2.81
Couldn't find git info
######## z3 #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/z3/init.py
Pip version z3-solver 4.10.2.0
Couldn't find git info
######## unicorn #########
Python found it in /home/squ/.local/lib/python3.10/site-packages/unicorn/init.py
Pip version unicorn 2.0.1.post1
Couldn't find git info
######### Native Module Info ##########
angr: <CDLL '/home/squ/.local/lib/python3.10/site-packages/angr/state_plugins/../lib/angr_native.so', handle 55c215f60590 at 0x7f463e041d80>
unicorn: <CDLL '/home/squ/.local/lib/python3.10/site-packages/unicorn/lib/libunicorn.so.2', handle 55c215a70b20 at 0x7f4640d21630>
pyvex: <cffi.api._make_ffi_library..FFILibrary object at 0x7f4641a1e320>
z3: <CDLL '/home/squ/.local/lib/python3.10/site-packages/z3/lib/libz3.so', handle 55c215737340 at 0x7f4643bfb7c0>
Additional context
No response