Security audit methodology, checklists, and tools for identifying vulnerabilities in Solidity smart contracts. Use when reviewing contracts for security issues or performing comprehensive audits.
This skill inherits all available tools. When active, it can use any tool Claude has access to.
checklists/access-control-checklist.mdchecklists/common-vulnerabilities.mdchecklists/defi-checklist.mdchecklists/token-checklist.mdchecklists/upgrade-checklist.mdtemplates/audit-report-template.mdThis skill provides methodology, checklists, and templates for conducting security audits of Solidity smart contracts.
Use this skill when:
Understand the System:
Set Scope:
Tools to run:
# Static analysis with Slither
slither . --detect all
# Mythril symbolic execution
myth analyze contracts/MyContract.sol
# Aderyn static analyzer
aderyn .
# Gas optimization with Foundry
forge test --gas-report
# Code coverage
forge coverage
# Mutation testing
vertigo run
Key tools:
See ./checklists/ for comprehensive review checklists:
Test Coverage Analysis:
Test Quality:
Code Documentation:
External Documentation:
Reentrancy
Access Control
Integer Issues
Unchecked External Calls
Logic Errors
Front-Running
Denial of Service
Oracle Manipulation
Token Issues
Gas Optimization
Code Quality
function withdraw(uint256 amount) public {
// 1. CHECKS
require(balances[msg.sender] >= amount, "Insufficient balance");
// 2. EFFECTS
balances[msg.sender] -= amount;
// 3. INTERACTIONS
(bool success, ) = msg.sender.call{value: amount}("");
require(success, "Transfer failed");
}
// ❌ BAD: Push payments
function distributeRewards() public {
for (uint i = 0; i < users.length; i++) {
users[i].transfer(rewards[users[i]]);
}
}
// ✅ GOOD: Pull payments
function claimReward() public {
uint256 reward = rewards[msg.sender];
require(reward > 0, "No reward");
rewards[msg.sender] = 0;
payable(msg.sender).transfer(reward);
}
mapping(address => uint256) public lastActionTime;
uint256 public constant COOLDOWN = 1 hours;
function sensitiveAction() public {
require(
block.timestamp >= lastActionTime[msg.sender] + COOLDOWN,
"Cooldown not expired"
);
lastActionTime[msg.sender] = block.timestamp;
// Action logic
}
import "@openzeppelin/contracts/security/Pausable.sol";
contract MyContract is Pausable {
function criticalFunction() public whenNotPaused {
// Protected by pause mechanism
}
function pause() public onlyOwner {
_pause();
}
}
# Basic analysis
slither .
# Specific detectors
slither . --detect reentrancy-eth,unchecked-transfer
# Generate report
slither . --json slither-report.json
# Check upgradeability
slither-check-upgradeability . MyContract
# Human-readable summary
slither . --print human-summary
# Analyze specific contract
myth analyze contracts/MyContract.sol
# With specific modules
myth analyze contracts/MyContract.sol -m IntegerOverflow,Reentrancy
# Generate report
myth analyze contracts/MyContract.sol -o json > mythril-report.json
# Basic scan
aderyn .
# Generate markdown report
aderyn . --output report.md
# Specific severity
aderyn . --severity high,medium
# Fuzz test with config
echidna-test contracts/MyContract.sol --config echidna.yaml
# Specific test contract
echidna-test contracts/MyContract.sol --contract TestContract
See ./templates/audit-report-template.md for a comprehensive audit report structure.
Report sections:
Example: Reentrancy allowing unlimited withdrawals
Example: Missing access control on admin function
Example: Front-running opportunity affecting fairness
Example: Use of magic numbers instead of constants
Example: Missing NatSpec comments
This skill works with:
| Task | Tool | Command |
|---|---|---|
| Static analysis | Slither | slither . |
| Symbolic execution | Mythril | myth analyze contracts/ |
| Modern analysis | Aderyn | aderyn . |
| Fuzzing | Echidna | echidna-test contracts/ |
| Coverage | Foundry | forge coverage |
| Gas report | Foundry | forge test --gas-report |
Remember: Security is not a one-time check. Conduct regular audits, especially after significant changes. Consider external audits for production systems handling significant value.