Overview
ChainProof currently has no rule for detecting broken access control patterns — one of the most common and highest-impact vulnerability classes in smart contracts. The existing CP-115 rule only covers tx.origin misuse, but there are many broader patterns that lead to unauthorized privilege escalation.
Vulnerability Patterns to Detect
1. Missing Access Control on Sensitive Functions
// No modifier or msg.sender check — anyone can call
function setOwner(address newOwner) external {
owner = newOwner;
}
2. Unprotected Initialization Functions
bool initialized;
function initialize(address admin) external {
owner = admin;
}
3. Role Assignment Without Sender Verification
function grantRole(bytes32 role, address account) external {
roles[account] = role; // no check that msg.sender has the authority to grant
}
4. Delegatecall to User-Supplied Address
function execute(address target, bytes calldata data) external {
target.delegatecall(data); // attacker controls target
}
Proposed Rule: CP-116
Detection heuristics via AST analysis:
- Sensitive function naming heuristic — functions named
set*, update*, initialize*, upgrade*, withdraw*, mint*, burn* that have no onlyOwner-style modifier and no require(msg.sender == ...) guard
- Unchecked role grant — assignment to a mapping that stores roles without verifying caller has the admin role
- Delegatecall to input address — any
delegatecall where the target is a function parameter
Acceptance Criteria
References
Overview
ChainProof currently has no rule for detecting broken access control patterns — one of the most common and highest-impact vulnerability classes in smart contracts. The existing CP-115 rule only covers
tx.originmisuse, but there are many broader patterns that lead to unauthorized privilege escalation.Vulnerability Patterns to Detect
1. Missing Access Control on Sensitive Functions
2. Unprotected Initialization Functions
3. Role Assignment Without Sender Verification
4. Delegatecall to User-Supplied Address
Proposed Rule: CP-116
Detection heuristics via AST analysis:
set*,update*,initialize*,upgrade*,withdraw*,mint*,burn*that have noonlyOwner-style modifier and norequire(msg.sender == ...)guarddelegatecallwhere the target is a function parameterAcceptance Criteria
packages/core/src/rules/swc116-access-control.tsonlyOwner,onlyAdmin,onlyRolestyle modifiers and check if they are applied)Ownablepattern (detected via import heuristic)References