Back to Skills

smart-contract-vulnerabilities

Smart contract vulnerability playbook. Use when auditing Solidity/EVM contracts for reentrancy, integer overflow, access control, delegatecall, flash loan, signature replay, and MEV-related attack patterns.

1,311stars179forksUpdated 7/8/2026

Security Assessment

Safe(100/100)
Security Score100/100

About smart-contract-vulnerabilities

A vulnerability playbook for auditing Solidity/EVM smart contracts, organized as an expert attack reference across the major smart-contract bug classes. It is intended for reviewing contracts for reentrancy, integer overflow/underflow, access-control flaws, unsafe delegatecall, weak on-chain randomness, flash-loan and MEV-related patterns, signature replay, and self-destruct/force-send issues. The material emphasizes subtle cases that base models tend to miss, such as cross-contract and read-only reentrancy and storage-layout collisions in proxy patterns.

Reentrancy is treated in depth: classic single-function, cross-function (two functions sharing state), cross-contract, and read-only reentrancy where a view function used by a third party for pricing returns stale intermediate state, illustrated with the Curve get_virtual_price example. Documented mitigations include Checks-Effects-Interactions, OpenZeppelin's ReentrancyGuard mutex, and pull-payment patterns. Other sections cover pre- and post-Solidity 0.8 arithmetic (silent wrapping versus unchecked blocks, SafeMath bypasses via casting and assembly), tx.origin versus msg.sender authentication, unprotected selfdestruct and delegatecall, predictable randomness sources such as block.timestamp and prevrandao, delegatecall storage-slot and function-selector collisions, sandwich and front-running defenses, and EIP-712/nonce signature-replay errors including cross-chain replay.

Use it when performing a security audit or threat assessment of on-chain code, when triaging a suspected exploit class, or as a checklist while writing or reviewing contracts. Each topic pairs the failure mechanism with concrete impact and defensive patterns, presented in tables and annotated call-flow diagrams. It also routes to related references, defi-attack-patterns for protocol-level exploits and deserialization-insecure for off-chain infrastructure, and points to an advanced SOLIDITY_VULN_PATTERNS.md companion with side-by-side vulnerable/fixed code, gas-optimization traps, and proxy storage-collision slot calculations. The content is descriptive and defense-oriented, mapping how each attack works so reviewers can recognize and close the corresponding gap.

FAQ

Which vulnerability classes does this playbook cover?

Reentrancy (single, cross-function, cross-contract, read-only), integer overflow/underflow, access control, delegatecall, randomness manipulation, front-running/MEV, signature replay, and self-destruct/force-send.

What kinds of reentrancy does it distinguish?

It separates classic single-function, cross-function, cross-contract, and read-only reentrancy, the last of which misleads a third-party contract reading a view function during a callback.

How does it recommend defending against reentrancy?

Through Checks-Effects-Interactions (updating state before external calls), OpenZeppelin's ReentrancyGuard mutex, and the pull-payment pattern, with CEI plus guards on public functions as defense-in-depth.

Does it address proxy and delegatecall risks?

Yes. It explains storage-layout slot collisions where an implementation overwrites the proxy's owner, and function-selector collisions, and points to a companion file with slot-calculation examples.

Is integer overflow still relevant after Solidity 0.8?

The default checked arithmetic reverts on overflow, but unchecked{} blocks reintroduce risk, and SafeMath can still be bypassed via truncating casts, assembly, or intermediate-multiplication overflow.

All Files

2 files
SKILL.md11.6 KB
View
SOLIDITY_VULN_PATTERNS.md11.4 KB
View

Install smart-contract-vulnerabilities

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill