agentleFS
forefyforefy/.context/skills/blockchain/safe-hunt/SKILL.md

safe-hunt

Skill153 starsChanged 45 days agoMITView on GitHub

Sweeps DeFi protocol Safe multisig wallets for governance misconfigurations and security weaknesses. Given a protocol name, Safe address, or "sweep all", fetches live config and tx history from the Safe Transaction Service API, scores each Safe against a finding pattern library, and produces an audit-ready ranked report. Use when auditing a protocol's admin controls, hunting for misconfigured multisigs, or generating governance risk leads across DeFi.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If unclear, ask: "Do you want to audit a specific Safe address, a named protocol, or sweep all DeFiLlama protocols?"

    line 52
  2. Very specific:

    Use scripts/sweep.py for Mode 2/3 - it handles DeFiLlama parsing, Safe API calls, scoring, and report generation.

    line 56
  3. Very specific:

    If script unavailable, do manual discovery per references/defillama-discovery.md.

    line 58
  4. Distinctive:

    Only read public on-chain data - Safe API is fully public, no credentials required

    line 131
  5. Distinctive:

    Do not send transactions, trigger signatures, or interact with Safe UI

    line 132

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Safe Governance Hunt Skill

Identity

Protocol governance security analyst. Systematically assess Safe multisig configurations across DeFi protocols using live on-chain data via the Safe Transaction Service API. No auth required. Read-only - never send transactions, never modify state. Findings are ranked by severity and formatted as audit-ready report items. Ambiguous findings → document with evidence and flag for manual review. Never conclude "exploitable" without on-chain confirmation.


Reference Files

Load on demand:

FileLoad When
references/safe-api.mdMaking any Safe API call - endpoints, base URLs, response shapes
references/finding-patterns.mdScoring any Safe - full criteria, severity thresholds, audit language
references/defillama-discovery.mdMode = sweep or protocol - how to extract Safe addresses from DeFiLlama

Modes

Mode 1: Targeted

Input: one or more Safe addresses + optional network (default: ethereum). → Deep audit of each Safe: config + 50 most recent txs + full finding set.

Mode 2: Protocol

Input: protocol name (e.g. "Aave", "Compound"). → Look up protocol in DeFiLlama treasury adapters → extract Safe addresses → run targeted audit on each.

Mode 3: Sweep

Input: "sweep all" or no address given. → Parse all ~292 DeFiLlama treasury adapters → extract all Safe addresses → run targeted audit on each → output ranked leaderboard by risk score.


Engagement Protocol

Step 0 - Determine mode:

  • Address(es) provided → Mode 1 (Targeted)
  • Protocol name provided → Mode 2 (Protocol) - load references/defillama-discovery.md
  • "sweep", "all protocols", or no input → Mode 3 (Sweep) - load references/defillama-discovery.md
  • If unclear, ask: "Do you want to audit a specific Safe address, a named protocol, or sweep all DeFiLlama protocols?"

Step 1 - Discover addresses (skip for Mode 1):

  • Use scripts/sweep.py for Mode 2/3 - it handles DeFiLlama parsing, Safe API calls, scoring, and report generation.
  • Run: python3 ~/.claude/skills/safe-hunt/scripts/sweep.py [--protocol <name>] [--address <0x>] [--network <net>] [--output report.md]
  • If script unavailable, do manual discovery per references/defillama-discovery.md.

Step 2 - Fetch Safe config + tx history (for manual/targeted flow): Load references/safe-api.md for exact endpoints. Fetch:

  1. GET /api/v1/safes/{address}/ → config
  2. GET /api/v1/safes/{address}/multisig-transactions/?limit=50&ordering=-nonce → recent txs

Step 3 - Score findings: Load references/finding-patterns.md. Evaluate every pattern against the fetched data.

Step 4 - Report: Output per finding-patterns.md report format. Always include: Safe address, network, protocol name, risk score, findings sorted by severity, evidence, audit language.


Script Usage

# Audit one Safe
python3 ~/.claude/skills/safe-hunt/scripts/sweep.py --address 0xABC... --network ethereum

# Audit a protocol by name (DeFiLlama lookup)
python3 ~/.claude/skills/safe-hunt/scripts/sweep.py --protocol "Lido"

# Full DeFiLlama sweep (slow - ~292 protocols)
python3 ~/.claude/skills/safe-hunt/scripts/sweep.py --sweep --output sweep_report.md

# Sweep with network filter
python3 ~/.claude/skills/safe-hunt/scripts/sweep.py --sweep --network ethereum --top 20

Report Format

# Safe Governance Hunt Report
Generated: <date> | Mode: <targeted|protocol|sweep> | Network: <network>

## 🔴 CRITICAL / HIGH RISK

### [Protocol Name] - 0xSafeAddress (ethereum)
Risk Score: 85/100
Owners: 3 | Threshold: 1/3 | Version: 1.2.0 | Guard: None | Modules: 1 unknown

**[HIGH] Single-signer threshold (1/3)**
Any single owner can execute transactions unilaterally without consensus.
Evidence: threshold=1, owners=3
Audit language: "The Safe multisig securing [protocol] admin functions is configured with a 1-of-3 threshold, effectively granting any single signer unilateral control over privileged operations including [X]. This constitutes a critical centralization risk."

**[HIGH] Unknown module enabled**
Module 0x1234... has unrestricted access to all Safe assets and is not in the known-safe module registry.
Evidence: module=0x1234..., not in whitelist
Audit language: "An unverified module (0x1234...) is enabled on the Safe, granting it the ability to execute arbitrary transactions. If compromised or malicious, this module bypasses the multisig threshold entirely."

---

## 🟠 MEDIUM RISK
...

## 🟡 LOW RISK / INFORMATIONAL
...

## ✅ CLEAN SAFES
The following Safes had no findings:
- [Protocol] 0xABC... (ethereum) - Score: 0

Scope

  • Only read public on-chain data - Safe API is fully public, no credentials required
  • Do not send transactions, trigger signatures, or interact with Safe UI

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.