ckorhonen/claude-skills/blockchain-auditor

Claude Code and agent skill by ckorhonen/claude-skills

Trust tier 2
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Security audit smart contracts for exploitable vulnerabilities from an unprivileged context. Use when analyzing Solidity contracts, reviewing bytecode, testing exploits on forks, or searching for ways to extract funds without owner access. Covers verified and unverified contracts, bytecode disassembly, vulnerability ranking, proof-of-concept exploit generation, DeFi protocol attacks, and cross-chain bridge security.

Install

npx vskill@latest install ckorhonen/claude-skills/blockchain-auditor

SKILL.md

Blockchain Security Auditor

Systematically audit smart contracts to identify exploitable vulnerabilities that allow an unprivileged account to extract funds or gain unauthorized access.

Quick Start

bash
# For verified contracts (Etherscan source available)
cast etherscan-source <address> --chain mainnet
# For unverified contracts (bytecode only)
cast code <address> --rpc-url $ETH_RPC_URL
cast disassemble <bytecode>
# Fork testing
forge test --fork-url $ETH_RPC_URL -vvv
# Static analysis
slither . --checklist

Audit Methodology

Phase 1: Reconnaissance
  1. Gather contract information:

```bash # Check balance cast balance <address> --rpc-url $ETH_RPC_URL

# Get bytecode cast code <address> --rpc-url $ETH_RPC_URL

# Check if verified on Etherscan curl "https://api.etherscan.io/api?module=contract&action=getsourcecode&address=<address>&apikey=$ETHERSCAN_API_KEY"

# Check for proxy implementation cast storage <address> 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc --rpc-url $ETH_RPC_URL ```

  1. Identify contract type:
  • Multi-sig wallet (addOwner, execute, confirmTransaction)
  • Token contract (transfer, approve, balanceOf)
  • DeFi protocol (deposit, withdraw, swap, liquidate)
  • Lending/borrowing (Compound/Aave-style)
  • AMM/DEX (Uniswap v2/v3-style with liquidity pools)
  • Proxy pattern (EIP-1967, UUPS, Transparent, Beacon)
  • Vault/yield aggregator (ERC-4626)
  • Cross-chain bridge (lock/mint, burn/release)
  • NFT contract (ERC-721, ERC-1155)
Phase 2: Source Code Analysis (Verified Contracts)
  1. Identify high-risk functions:
  • selfdestruct / suicide - can drain all ETH
  • delegatecall - can execute arbitrary code
  • call with user-controlled data - arbitrary calls
  • transfer / send without checks - reentrancy
  • withdraw / claim / redeem - fund extraction points
  • initialize / init - proxy initialization (can it be called twice?)
  • permit / permitAll - off-chain approval bypass
  • flash / flashLoan - flash loan entry points
  1. Check access control patterns:

``solidity // Weak patterns to look for: require(tx.origin == owner); // tx.origin bypass require(msg.sender == owner); // Check if owner is compromised // Missing modifier on sensitive function function withdraw() public { // No onlyOwner! payable(msg.sender).transfer(address(this).balance); } // Proxy: unprotected initialize function initialize(address _owner) public { // Missing initializer modifier! owner = _owner; } ``

  1. Known vulnerability patterns:
  • Reentrancy (state change after external call)
  • Integer overflow/underflow (Solidity < 0.8.0)
  • Unchecked return values
  • Front-running susceptibility
  • Flash loan attacks (price manipulation in single tx)
  • Price oracle manipulation (spot vs TWAP)
  • Permit/EIP-2612 signature replay
  • ERC777 callback reentrancy
  • Read-only reentrancy (view functions misused in logic)
  • Donation attacks (token balance inflation)
  • First depositor share inflation (ERC-4626 vaults)
Phase 3: DeFi-Specific Attack Vectors

For DeFi protocols, these vectors are highest-value and commonly exploitable:

  1. Price Oracle Manipulation:

``solidity // Vulnerable: spot price used as oracle function getPrice() public view returns (uint256) { (uint112 reserve0, uint112 reserve1,) = IUniswapV2Pair(pool).getReserves(); return reserve1 * 1e18 / reserve0; // Manipulable in a single tx! } // Attack: flash loan → manipulate pool → call vulnerable function → repay ``

  • Check if protocol uses spot prices anywhere
  • TWAP oracles are safe; Chainlink feeds are safe (within heartbeat)
  • Look for getReserves(), slot0(), direct AMM pool queries
  1. Flash Loan Attack Surface:
  • Can any state-changing function be called with borrowed funds?
  • Check: borrow large amount → do something → repay in same tx
  • Key question: does the protocol measure prices/balances before or after user deposits?
  1. Reentrancy Variants:

```solidity // Cross-function reentrancy function withdraw() external { // State updated after transfer → reenter via deposit() IERC20(token).safeTransfer(msg.sender, amounts[msg.sender]); amounts[msg.sender] = 0; // Too late! }

// Read-only reentrancy (in Curve, Balancer) // Attack: during callback, totalSupply() returns old value // Another protocol reads it via getVirtualPrice() during the callback ```

  1. ERC-4626 Vault Inflation Attack:
  • First depositor can inflate share price by donating tokens
  • Target: protocols that mint shares = (deposit * totalShares) / totalAssets
  • If totalShares = 0, first depositor gets deposit shares; then donate to inflate
  1. Signature/Permit Vulnerabilities:

```solidity // EIP-2612 permit can be front-run // Front-runner takes the permit, uses it themselves before victim's tx // Safe if permit is used atomically in the same tx

// Check: does permit use chainId? (cross-chain replay) // Check: does it use nonces? (replay protection) ```

  1. Governance/Timelock Attacks:
  • Can governance propose and execute malicious upgrades?
  • Is there a timelock? How long?
  • Can flash loan voting power bypass quorum?
Phase 4: Bytecode Analysis (Unverified Contracts)
  1. Disassemble bytecode:

``bash cast disassemble <bytecode> > contract.asm ``

  1. Extract function selectors:

``bash # Look for PUSH4 followed by 4 bytes grep -oE '63[0-9a-f]{8}' contract.asm | cut -c3-10 | sort -u ``

  1. Look up signatures:

``bash curl "https://www.4byte.directory/api/v1/signatures/?hex_signature=0x<selector>" # Also try openchain.xyz/signature-database ``

  1. Identify dangerous opcodes:
OpcodeHexRisk
SELFDESTRUCTffCritical - destroys contract
DELEGATECALLf4High - arbitrary code execution
CALLf1Medium - external calls
CALLCODEf2High - deprecated, dangerous
CREATE2f5Medium - deterministic deployment
TLOAD/TSTORE5c/5dNew in EIP-1153 - transient storage
  1. Analyze control flow:
  • Find JUMPDEST locations for function entry points
  • Trace CALLER/ORIGIN checks for access control
  • Look for SLOAD/SSTORE patterns for state access
Phase 5: Vulnerability Ranking

Rate each finding by exploitation likelihood given current blockchain state:

RatingCriteriaAction
CriticalDirectly exploitable now, high valueImmediate PoC
HighExploitable with specific conditions metFork test
MediumRequires unlikely conditionsDocument
LowTheoretical, conditions very unlikelyNote only

Factors affecting likelihood:

  • Current blockchain state (owner keys, time locks, balances)
  • Required preconditions (deposits, approvals, block numbers)
  • Gas costs vs potential gain
  • MEV/frontrunning risks (can an attacker sandwich?)
  • Flashbots private mempool availability
Phase 6: Fork Validation
  1. Set up Foundry test:

```solidity // test/Exploit.t.sol pragma solidity ^0.8.20; import "forge-std/Test.sol"; import "forge-std/interfaces/IERC20.sol";

interface IFlashLoanProvider { function flashLoan(uint256 amount) external; }

contract ExploitTest is Test { address target = 0x<TARGET_ADDRESS>; address attacker;

function setUp() public { // Fork at specific block for determinism vm.createSelectFork(vm.envString("ETH_RPC_URL"), <BLOCK_NUMBER>); attacker = makeAddr("attacker"); vm.deal(attacker, 1 ether); }

function test_exploit() public { uint256 balanceBefore = attacker.balance;

vm.prank(attacker); (bool success,) = target.call(abi.encodeWithSelector(0x<SELECTOR>));

uint256 balanceAfter = attacker.balance;

// CRITICAL: Verify actual fund extraction assertGt(balanceAfter, balanceBefore, "Exploit failed - no funds extracted"); }

// Flash loan exploit template function test_flashLoanExploit() public { uint256 targetBalanceBefore = IERC20(token).balanceOf(target);

vm.prank(attacker); FlashLoanAttacker exploitContract = new FlashLoanAttacker(target); exploitContract.attack();

assertLt(IERC20(token).balanceOf(target), targetBalanceBefore, "No drain"); assertGt(IERC20(token).balanceOf(attacker), 0, "No profit"); } } ```

  1. Run on fork:

``bash forge test --fork-url $ETH_RPC_URL -vvvv --match-test "test_exploit" ``

  1. Verify fund extraction (not just call success):
  • Check attacker balance increased
  • Verify target balance decreased
  • Confirm contract state changed as expected
  • Call success does NOT mean exploit success
Phase 7: Report Generation

For confirmed vulnerabilities, create a report:

markdown
# Vulnerability Report: [Contract Address]
## Summary
-**Severity**: Critical/High/Medium/Low
-**Type**: [Reentrancy/Access Control/Oracle Manipulation/etc.]
-**Impact**: [Amount at risk, what attacker gains]
-**Exploitable**: Yes/No (with current blockchain state)
-**Block confirmed**: [Block number of fork test]
## Vulnerable Function
\`\`\`solidity
function vulnerableFunction() public {
// Vulnerable code
}
\`\`\`
## Attack Vector
1.Attacker calls function X with parameter Y
2.Contract fails to check Z
3.Funds transferred to attacker
## Proof of Concept
\`\`\`solidity
// Foundry test that demonstrates the exploit
function test_exploit() public {
// Setup and exploit code
}
\`\`\`
## Execution Script (if confirmed)
\`\`\`bash
cast send <target> "vulnerableFunction()" --rpc-url $ETH_RPC_URL --private-key $PRIVATE_KEY
\`\`\`
## Remediation
-Add access control modifier
-Implement checks-effects-interactions pattern
-Use SafeMath for arithmetic (or upgrade to Solidity >= 0.8.0)
-Replace spot price with TWAP oracle

Common Vulnerability Checklist

Access Control
  • [ ] All sensitive functions have proper modifiers
  • [ ] Owner/admin addresses are not compromised
  • [ ] Multi-sig requires sufficient confirmations
  • [ ] Time locks are enforced
  • [ ] No tx.origin authentication
  • [ ] Proxy initializer cannot be called twice
  • [ ] UUPS upgrade function is access-controlled
  • [ ] Governance quorum cannot be bypassed with flash loans
Reentrancy
  • [ ] State changes before external calls (CEI pattern)
  • [ ] ReentrancyGuard used on fund transfers
  • [ ] No callbacks to untrusted contracts
  • [ ] ERC-777 tokensReceived hook considered
  • [ ] Cross-function reentrancy checked
  • [ ] Read-only reentrancy checked (getVirtualPrice, exchange rate)
Arithmetic (Solidity < 0.8.0)
  • [ ] SafeMath used for all operations
  • [ ] No unchecked blocks with user input
  • [ ] Proper bounds checking
  • [ ] Check for 0.5.x - 0.6.x overflow vulnerabilities
Oracle / Price Manipulation
  • [ ] No spot price oracles (flash-loan manipulable)
  • [ ] TWAP used where applicable
  • [ ] Chainlink heartbeat freshness checked
  • [ ] Multi-oracle aggregation for critical paths
  • [ ] Pool balances not used as price source
Flash Loans
  • [ ] State cannot be manipulated then read in same tx
  • [ ] No price/ratio checks after untrusted external calls
  • [ ] Reentrancy guard on all flash-loan-callable functions

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1
7-day trend score
3

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 Mar 2026, 8 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ckorhonen/claude-skills/blockchain-auditor/badge)](https://verified-skill.com/skills/ckorhonen/claude-skills/blockchain-auditor)

Something wrong with this skill or its page? Tell us.