Smart contract audit against YAML vulnerability patterns
Inputs you will receive
- Smart contract(s) — Solidity (or mixed) source: full files, snippets, or a single concatenated bundle. Note the compiler version and framework (Hardhat, Foundry, etc.) if stated.
- Patterns — YAML, typically a list of objects. Common fields (adapt if the file uses different keys):
id — pattern identifier
name — short title
severity — e.g. Critical / High / Medium / Low / Informational
description — what constitutes the vulnerability and what to look for in code
false_positives — mitigations or situations that should not be reported - Optional: cross_cluster_risk, tags, references, code hints
Treat the YAML as the single source of truth for what to check; do not invent extra vulnerability types unless the user asks.
What you must do
- Parse the YAML mentally: for each pattern, extract the checks implied by
description and the exclusions from false_positives.
- Walk the contract code (logic, modifiers, external calls, access control, asset flows, cross-chain / compose / paymaster / ERC quirks as relevant).
- For each pattern, decide:
- Match — the contract exhibits the risky behavior and
false_positives does not clearly apply.
- No match — behavior absent or adequately mitigated (cite mitigations when relevant).
- Uncertain — insufficient code or context; say what is missing.
- Prefer precision over volume: only report findings where the pattern text reasonably applies. When in doubt after applying
false_positives, mark uncertain rather than forcing a finding.
Output: JSON only for the findings block
Return a single JSON object (valid JSON, no markdown fences required unless the host asks). Schema:
{
"summary": {
"patterns_checked": <number>,
"findings_count": <number>,
"contracts_reviewed": ["<file or label>", "..."]
},
"findings": [
{
"pattern_id": "<from YAML id>",
"pattern_name": "<from YAML name>",
"severity": "<from YAML severity>",
"status": "match",
"title": "<short human title>",
"description": "<why this applies to the contract>",
"evidence": [
{
"location": "<contract: function or line hint>",
"snippet": "<relevant code excerpt, abbreviated if long>"
}
],
"recommendation": "<concrete fix or verification step>",
"false_positive_check": "<brief note on why false_positives do not apply, or N/A>"
}
],
"non_matches": [
{
"pattern_id": "<id>",
"pattern_name": "<name>",
"note": "<one line: absent or mitigated>"
}
],
"uncertain": [
{
"pattern_id": "<id>",
"pattern_name": "<name>",
"reason": "<what is missing or ambiguous>"
}
]
}
Rules
findings: include only entries with "status": "match". Omit the array or use [] if there are no matches.
non_matches: optional but useful when the user wants full coverage; cap length if there are hundreds of patterns (then summarize counts and list only matches + uncertain).
uncertain: use when you cannot verify without tests, deployment config, or off-chain components.
- Preserve exact
pattern_id and severity from YAML where present.
Quality bar
- Tie each finding to specific functions, state variables, or control flow in the supplied code.
- Respect
false_positives: if the contract clearly implements those mitigations, do not emit a finding for that pattern.
- Do not hallucinate file names; use
"unknown" or the label the user gave if paths are missing.
1---2name: smart-contract-yaml-pattern-audit3description: Audits smart contract source against vulnerability patterns supplied as YAML. Use when the user provides contract code and a YAML pattern list (e.g. id, name, severity, description, false_positives) and expects a structured JSON report of matches and rationale.4---5
6# Smart contract audit against YAML vulnerability patterns
7
8## Inputs you will receive
9
101. **Smart contract(s)** — Solidity (or mixed) source: full files, snippets, or a single concatenated bundle. Note the compiler version and framework (Hardhat, Foundry, etc.) if stated.
112. **Patterns** — YAML, typically a list of objects. Common fields (adapt if the file uses different keys):
12 - `id` — pattern identifier
13 - `name` — short title
14 - `severity` — e.g. Critical / High / Medium / Low / Informational
15 - `description` — what constitutes the vulnerability and what to look for in code
16 - `false_positives` — mitigations or situations that should **not** be reported - Optional: `cross_cluster_risk`, tags, references, code hints
17
18Treat the YAML as the **single source of truth** for what to check; do not invent extra vulnerability types unless the user asks.
19
20## What you must do
21
221. **Parse the YAML** mentally: for each pattern, extract the checks implied by `description` and the exclusions from `false_positives`.
232. **Walk the contract code** (logic, modifiers, external calls, access control, asset flows, cross-chain / compose / paymaster / ERC quirks as relevant).
243. For **each pattern**, decide:
25 - **Match** — the contract exhibits the risky behavior and `false_positives` does not clearly apply.
26 - **No match** — behavior absent or adequately mitigated (cite mitigations when relevant).
27 - **Uncertain** — insufficient code or context; say what is missing.
284. Prefer **precision over volume**: only report findings where the pattern text reasonably applies. When in doubt after applying `false_positives`, mark uncertain rather than forcing a finding.
29
30## Output: JSON only for the findings block
31
32Return a **single JSON object** (valid JSON, no markdown fences required unless the host asks). Schema:
33
34```json
35{
36 "summary": {
37 "patterns_checked": <number>,
38 "findings_count": <number>,
39 "contracts_reviewed": ["<file or label>", "..."]
40 },
41 "findings": [
42 {
43 "pattern_id": "<from YAML id>",
44 "pattern_name": "<from YAML name>",
45 "severity": "<from YAML severity>",
46 "status": "match",
47 "title": "<short human title>",
48 "description": "<why this applies to the contract>",
49 "evidence": [
50 {
51 "location": "<contract: function or line hint>",
52 "snippet": "<relevant code excerpt, abbreviated if long>"
53 }
54 ],
55 "recommendation": "<concrete fix or verification step>",
56 "false_positive_check": "<brief note on why false_positives do not apply, or N/A>"
57 }
58 ],
59 "non_matches": [
60 {
61 "pattern_id": "<id>",
62 "pattern_name": "<name>",
63 "note": "<one line: absent or mitigated>"
64 }
65 ],
66 "uncertain": [
67 {
68 "pattern_id": "<id>",
69 "pattern_name": "<name>",
70 "reason": "<what is missing or ambiguous>"
71 }
72 ]
73}
74```
75
76### Rules
77
78- **`findings`**: include only entries with `"status": "match"`. Omit the array or use `[]` if there are no matches.
79- **`non_matches`**: optional but useful when the user wants full coverage; cap length if there are hundreds of patterns (then summarize counts and list only matches + uncertain).
80- **`uncertain`**: use when you cannot verify without tests, deployment config, or off-chain components.
81- Preserve **exact** `pattern_id` and severity from YAML where present.
82
83## Quality bar
84
85- Tie each finding to **specific functions, state variables, or control flow** in the supplied code.
86- Respect **`false_positives`**: if the contract clearly implements those mitigations, do not emit a finding for that pattern.
87- Do not hallucinate file names; use `"unknown"` or the label the user gave if paths are missing.