Skip to content

Unprotected selfdestruct

SAFE-0116 Access Control Checked automatically by the scanner
1

What goes wrong

A selfdestruct (or its alias) is reachable from a function with no access control. Anyone can destroy the contract, delete its code, and forward its entire balance to an arbitrary address — an instant, irreversible loss of the contract and its funds.

2

The vulnerable pattern

proof of concept — how it is exploited
// contract Victim { function close() public { selfdestruct(payable(msg.sender)); } }
// attacker calls close() -> code wiped, remaining ETH sent to attacker.
3

How to fix it

the pattern that is safe
function kill() external onlyOwner {
    selfdestruct(payable(owner()));
}
Parity multisig freeze (2017). Gate or remove selfdestruct.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0116 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs