Skip to content

Commit

Permalink
fix: detect selfdestruct in internal calls (crytic#2232)
Browse files Browse the repository at this point in the history
* fix: detect selfdestruct in internal calls

* update snapshot
  • Loading branch information
0xalpharush authored and talfao committed Apr 27, 2024
1 parent 04426e0 commit cda9a9d
Show file tree
Hide file tree
Showing 4 changed files with 11 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
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
C.i_am_a_backdoor2(address) (tests/e2e/detectors/test_data/suicidal/0.7.6/suicidal.sol#8-10) allows anyone to destruct the contract

C.i_am_a_backdoor() (tests/e2e/detectors/test_data/suicidal/0.7.6/suicidal.sol#4-6) allows anyone to destruct the contract

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 cda9a9d

Please sign in to comment.