Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: detect selfdestruct in internal calls #2232

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 not shown.