Skip to content

Commit

Permalink
fix: detect selfdestruct in internal calls
Browse files Browse the repository at this point in the history
  • Loading branch information
0xalpharush committed Nov 15, 2023
1 parent fbd578a commit 6b33325
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion slither/detectors/functions/suicidal.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def detect_suicidal_func(func: FunctionContract) -> bool:
if func.visibility not in ["public", "external"]:
return False

calls = [c.name for c in func.internal_calls]
calls = [c.name for c in func.all_internal_calls()]
if not ("suicide(address)" in calls or "selfdestruct(address)" in calls):
return False

Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/detectors/test_data/suicidal/0.7.6/suicidal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ contract C{
selfdestruct(msg.sender);
}

function i_am_a_backdoor2(address payable to) public{
internal_selfdestruct(to);
}

function internal_selfdestruct(address payable to) internal {
selfdestruct(to);
}

}
Binary file modified tests/e2e/detectors/test_data/suicidal/0.7.6/suicidal.sol-0.7.6.zip
Binary file not shown.

0 comments on commit 6b33325

Please sign in to comment.