defi-security

A security checklist for decentralized finance, or DeFi, projects such as exchanges, lending services, staking systems, and yield products, before they go live on a blockchain network.

In plain words
What is it for?
Use it to review transaction limits, oracle pricing, approvals, reentrancy protection, flash-loan checks, governance delays, and other DeFi safety measures before mainnet deployment.
Why use it?
It helps developers check protections against threats such as reentrancy, price manipulation, flash loans, and governance attacks before deployment. It is not intended for non-DeFi projects.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/0xlayerghost/solidity-agent-kit/defi-security
Any agent
npx skills add 0xlayerghost/solidity-agent-kit --skill defi-security
Clone the repo
git clone --depth 1 https://github.com/0xlayerghost/solidity-agent-kit

Made for: Claude Code, Codex.

Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,509 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 94% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00063 $0.01509
Opus 5 $0.00032 $0.00754
Sonnet 5 $0.00013 $0.00302
Haiku 4.5 $0.00006 $0.00151

Measured 2d ago against content hash 0c110bf7ba0e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

defi-security scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

94% identical to defi-security — 2 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/defi-security/SKILL.md · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

DeFi Security Principles

Language Rule

  • Always respond in the same language the user is using. If the user asks in Chinese, respond in Chinese. If in English, respond in English.

Scope: Only applicable to DeFi projects (DEX, lending, staking, LP, yield). Non-DeFi projects can ignore this skill.

Protection Decision Rules

Threat Required Protection
Whale manipulation Daily transaction caps + per-tx amount limits + cooldown window
MEV / sandwich attack EOA-only checks (msg.sender == tx.origin), or use commit-reveal pattern
Arbitrage Referral binding + liquidity distribution + fixed yield model + lock period
Reentrancy ReentrancyGuard on all external-call functions (see solidity-security skill)
Flash loan attack Check block.number change between operations, or use TWAP pricing
Price manipulation Chainlink oracle or TWAP — never rely on spot AMM reserves for pricing
Approval exploit Use safeIncreaseAllowance / safeDecreaseAllowance, never raw approve for user flows
Governance attack Voting requires snapshot + minimum token holding period; timelock ≥ 48h on proposal execution
ERC4626 inflation attack First deposit must enforce minimum amount or use virtual shares to prevent share dilution via rounding
Cross-vault trust bypass Router/Registry relay must verify vault authorization; never trust caller identity inside flash loan callbacks — EVMbench/noya H-08
Collateral ownership exploit Liquidation/staking operations must verify actual NFT/collateral ownership — EVMbench/benddao
Bonding curve manipulation ID/pricing params in create operations must be fully determined before external calls — EVMbench/phi H-06
DEX pair _transfer TOCTOU Never distinguish operation type by balance/reserve checks in _transfer — both directions are exploitable: buy vs removeLiquidity (pair→user) and sell vs addLiquidity (user→pair); use address whitelist only; new projects prefer Uniswap V4 Hook
Per-address state bypass Any mapping(address => ...) restriction (cooldown, max tx, max balance) can be bypassed via multi-address or transfer-then-trade; propagate restriction state on wallet-to-wallet transfers using max(_lastTxTime[to], _lastTxTime[from]) — never block.timestamp (griefing) or direct assignment (overwrite shortening)

Read the full file on GitHub · 88 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 88 lines · 63 tokens per session scan A 0c110bf7ba0e

Subscribe to this mod's changes

defi-security is a skill published in the GitHub repository 0xlayerghost/solidity-agent-kit (4 stars, last pushed 22d ago), licensed MIT. It adds 63 tokens to every session and 1,509 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 94% identical to defi-security, differing in 2 lines, and is treated as a copy.

Related

Other skills, from other repositories

web3-bug-classes

Complete reference for all 10 DeFi smart contract bug classes. Use this when hunting for specific vulnerability types, need attack patterns for accounting desync, access control, incomplete path, off-by-one, oracle manipulation, ERC4626 vaults, reentrancy, flash loans, signature replay, or proxy/upgrade bugs.

Awarexone/web3-bug-bounty-hunting-ai-skills · 72 tokens

web3-methodology-research

External research synthesis from Trail of Bits, SlowMist, ConsenSys, Immunefi, and Cyfrin. Use this for advanced audit methodology, Echidna/Medusa fuzzing setup, Slither custom detector writing, attack pattern deep dives, or the 4-phase learning roadmap.

Awarexone/web3-bug-bounty-hunting-ai-skills · 66 tokens

web3-poc-foundry

Complete Foundry PoC writing guide + all cheatcodes + DeFiHackLabs reproduction patterns. Use this when building a proof of concept exploit, setting up a fork test, using Foundry cheatcodes, or reproducing a known DeFi hack for learning.

Awarexone/web3-bug-bounty-hunting-ai-skills · 59 tokens

web3-triage-report

Bug triage validation system, Immunefi report format, and 20 real paid bounty examples dissected. Use this when validating a finding before submitting, writing an Immunefi report, checking if a bug is actually valid, or studying real examples of paid vulnerabilities.

Awarexone/web3-bug-bounty-hunting-ai-skills · 59 tokens

web3-case-study-role-misconfig

Case study - role misconfiguration bug class applied to a yield aggregator protocol. Use as a template for applying all 10 bug classes to a single target.

Awarexone/web3-bug-bounty-hunting-ai-skills · 40 tokens

web3-grep-arsenal

Master grep command arsenal for Web3 smart contract auditing. Use when starting a new protocol scan, before deep code review, or when hunting specific vulnerability classes.

Awarexone/web3-bug-bounty-hunting-ai-skills · 39 tokens