Rules › Solidity
Privileged function without access control
A function that mints, withdraws, upgrades, pauses or changes ownership is public with no modifier or sender check.
Why it matters
Functions that mint, withdraw the treasury, upgrade, pause, set fees, oracles or owners are the keys to the contract. If one is public or external with no modifier and no sender check, anyone can call it. Access-control bugs are consistently the largest category of losses in smart-contract incidents.
Vulnerable
function setOwner(address newOwner) external {
owner = newOwner;
}
Fixed
function transferOwnership(address newOwner) public override onlyOwner {
super.transferOwnership(newOwner); // Ownable2Step: the new owner must accept
}
What other tools call it
| Tool | Detector or reference |
|---|---|
| Slither | arbitrary-send-eth, suicidal, unprotected-upgrade |
| Aderyn | centralization-risk |
| SWC registry | SWC-105, SWC-106 |
Check your code
Paste a contract into the in-browser checker, or let the Claude Code plugin scan before every deploy. The quick check for this rule is a pattern match: treat a hit as "look here", and a miss as no guarantee.
Related rules
- tx.origin used for authorization
- State written after an external call (reentrancy)
- Return value of a low-level call is ignored
- delegatecall to an address the caller controls
- Initializer anyone can call
- selfdestruct in contract code
Static analysis finds known bug classes; it can't prove code is safe and isn't an audit. Get a professional audit before deploying code that will hold value.