|
|
@ -80,12 +80,15 @@ class IntegerOverflowUnderflowModule(DetectionModule): |
|
|
|
pre_hooks=["ADD", "MUL", "EXP", "SUB", "SSTORE", "JUMPI", "STOP", "RETURN"], |
|
|
|
pre_hooks=["ADD", "MUL", "EXP", "SUB", "SSTORE", "JUMPI", "STOP", "RETURN"], |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._overflow_cache = {} # type: Dict[int, bool] |
|
|
|
|
|
|
|
|
|
|
|
def reset_module(self): |
|
|
|
def reset_module(self): |
|
|
|
""" |
|
|
|
""" |
|
|
|
Resets the module |
|
|
|
Resets the module |
|
|
|
:return: |
|
|
|
:return: |
|
|
|
""" |
|
|
|
""" |
|
|
|
super().reset_module() |
|
|
|
super().reset_module() |
|
|
|
|
|
|
|
self._overflow_cache = {} |
|
|
|
|
|
|
|
|
|
|
|
def _execute(self, state: GlobalState) -> None: |
|
|
|
def _execute(self, state: GlobalState) -> None: |
|
|
|
"""Executes analysis module for integer underflow and integer overflow. |
|
|
|
"""Executes analysis module for integer underflow and integer overflow. |
|
|
@ -94,6 +97,10 @@ class IntegerOverflowUnderflowModule(DetectionModule): |
|
|
|
:return: Found issues |
|
|
|
:return: Found issues |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
address = _get_address_from_state(state) |
|
|
|
|
|
|
|
if self._overflow_cache.get(address, False): |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
opcode = state.get_current_instruction()["opcode"] |
|
|
|
opcode = state.get_current_instruction()["opcode"] |
|
|
|
|
|
|
|
|
|
|
|
funcs = { |
|
|
|
funcs = { |
|
|
@ -327,6 +334,8 @@ class IntegerOverflowUnderflowModule(DetectionModule): |
|
|
|
|
|
|
|
|
|
|
|
issue.debug = json.dumps(transaction_sequence, indent=4) |
|
|
|
issue.debug = json.dumps(transaction_sequence, indent=4) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
address = _get_address_from_state(ostate) |
|
|
|
|
|
|
|
self._overflow_cache[address] = True |
|
|
|
self._issues.append(issue) |
|
|
|
self._issues.append(issue) |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
@ -341,3 +350,7 @@ class IntegerOverflowUnderflowModule(DetectionModule): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detector = IntegerOverflowUnderflowModule() |
|
|
|
detector = IntegerOverflowUnderflowModule() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_address_from_state(state): |
|
|
|
|
|
|
|
return state.get_current_instruction()["address"] |
|
|
|