Skip to content

Commit

Permalink
Merge pull request #146 from JoranHonig/bugfix/taintcheck
Browse files Browse the repository at this point in the history
Check if included expression is not prefixed by illegal character
  • Loading branch information
Bernhard Mueller authored Apr 27, 2018
2 parents dc8b07b + 12184db commit 0e63d7c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions mythril/analysis/modules/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,22 +210,31 @@ def _check_usage(state, expression):
return [state]
return []

def _check_taint(statement, expression):
"""Checks if statement is influenced by tainted expression"""
found = str(expression) in str(statement)

if found:
i = str(statement).index(str(expression))
char = str(statement)[i - 1]
if char == '_':
return False
return found

def _check_jumpi(state, expression):
""" Check if conditional jump is dependent on the result of expression"""
logging.info(state.get_current_instruction()['opcode'])
assert state.get_current_instruction()['opcode'] == 'JUMPI'
condition = state.mstate.stack[-2]
return str(expression) in str(condition)
return _check_taint(condition, expression)


def _check_sstore(state, expression):
""" Check if store operation is dependent on the result of expression"""
logging.info(state.get_current_instruction()['opcode'])
assert state.get_current_instruction()['opcode'] == 'SSTORE'
value = state.mstate.stack[-2]
return str(expression) in str(value)

return _check_taint(value, expression)

def _search_children(statespace, node, expression, index=0, depth=0, max_depth=64):
"""
Expand Down

0 comments on commit 0e63d7c

Please sign in to comment.