@vigolium/piolium 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/agents/access-auditor.md +300 -0
  4. package/agents/assumption-breaker.md +154 -0
  5. package/agents/attack-designer.md +116 -0
  6. package/agents/code-scanner.md +139 -0
  7. package/agents/concurrency-auditor.md +238 -0
  8. package/agents/confirm-writer.md +257 -0
  9. package/agents/context-reviewer.md +274 -0
  10. package/agents/cross-verifier.md +165 -0
  11. package/agents/cve-scout.md +381 -0
  12. package/agents/env-builder.md +282 -0
  13. package/agents/env-profiler.md +205 -0
  14. package/agents/evidence-collector.md +140 -0
  15. package/agents/finding-grader.md +142 -0
  16. package/agents/finding-writer.md +148 -0
  17. package/agents/flow-tracer.md +106 -0
  18. package/agents/goal-backtracer.md +146 -0
  19. package/agents/history-miner.md +467 -0
  20. package/agents/independent-verifier.md +118 -0
  21. package/agents/intent-mapper.md +183 -0
  22. package/agents/longshot-collector.md +128 -0
  23. package/agents/longshot-prober.md +126 -0
  24. package/agents/patch-auditor.md +73 -0
  25. package/agents/poc-author.md +124 -0
  26. package/agents/poc-runner.md +194 -0
  27. package/agents/probe-lead.md +269 -0
  28. package/agents/red-challenger.md +101 -0
  29. package/agents/report-composer.md +208 -0
  30. package/agents/review-adjudicator.md +216 -0
  31. package/agents/spec-auditor.md +155 -0
  32. package/agents/taint-tracer.md +265 -0
  33. package/agents/test-locator.md +209 -0
  34. package/agents/threat-modeler.md +132 -0
  35. package/agents/variant-scanner.md +108 -0
  36. package/agents/variant-spotter.md +110 -0
  37. package/bin/piolium.mjs +376 -0
  38. package/extensions/piolium/_vendor/yaml.bundle.d.mts +6 -0
  39. package/extensions/piolium/_vendor/yaml.bundle.mjs +139 -0
  40. package/extensions/piolium/agent-runner.ts +322 -0
  41. package/extensions/piolium/agents.ts +266 -0
  42. package/extensions/piolium/audit-state.ts +522 -0
  43. package/extensions/piolium/bundled-resources.ts +97 -0
  44. package/extensions/piolium/candidate-scan.ts +966 -0
  45. package/extensions/piolium/command-target.ts +177 -0
  46. package/extensions/piolium/console-stream.ts +57 -0
  47. package/extensions/piolium/export-results.ts +380 -0
  48. package/extensions/piolium/findings.ts +448 -0
  49. package/extensions/piolium/heartbeat.ts +182 -0
  50. package/extensions/piolium/help.ts +234 -0
  51. package/extensions/piolium/index.ts +1865 -0
  52. package/extensions/piolium/longshot.ts +530 -0
  53. package/extensions/piolium/matcher-suggestions.ts +196 -0
  54. package/extensions/piolium/matcher-utils.ts +83 -0
  55. package/extensions/piolium/modes/balanced.ts +750 -0
  56. package/extensions/piolium/modes/confirm-bootstrap.ts +186 -0
  57. package/extensions/piolium/modes/confirm.ts +697 -0
  58. package/extensions/piolium/modes/deep.ts +917 -0
  59. package/extensions/piolium/modes/diff.ts +177 -0
  60. package/extensions/piolium/modes/lite.ts +540 -0
  61. package/extensions/piolium/modes/longshot.ts +595 -0
  62. package/extensions/piolium/modes/merge.ts +204 -0
  63. package/extensions/piolium/modes/phase-runner.ts +267 -0
  64. package/extensions/piolium/modes/reinvest.ts +546 -0
  65. package/extensions/piolium/modes/revisit.ts +279 -0
  66. package/extensions/piolium/modes.ts +48 -0
  67. package/extensions/piolium/phase-labels.ts +123 -0
  68. package/extensions/piolium/phase-status-strip.ts +92 -0
  69. package/extensions/piolium/prompt-prefix-editor.ts +39 -0
  70. package/extensions/piolium/providers/anthropic-vertex.ts +836 -0
  71. package/extensions/piolium/recon.ts +409 -0
  72. package/extensions/piolium/result-stats.ts +105 -0
  73. package/extensions/piolium/retry.ts +120 -0
  74. package/extensions/piolium/scheduler.ts +212 -0
  75. package/extensions/piolium/secrets.ts +368 -0
  76. package/extensions/piolium/tools/web-tools.ts +148 -0
  77. package/package.json +77 -0
  78. package/skills/agentic-actions-auditor/SKILL.md +327 -0
  79. package/skills/agentic-actions-auditor/references/action-profiles.md +186 -0
  80. package/skills/agentic-actions-auditor/references/cross-file-resolution.md +209 -0
  81. package/skills/agentic-actions-auditor/references/foundations.md +94 -0
  82. package/skills/agentic-actions-auditor/references/vector-a-env-var-intermediary.md +77 -0
  83. package/skills/agentic-actions-auditor/references/vector-b-direct-expression-injection.md +83 -0
  84. package/skills/agentic-actions-auditor/references/vector-c-cli-data-fetch.md +83 -0
  85. package/skills/agentic-actions-auditor/references/vector-d-pr-target-checkout.md +88 -0
  86. package/skills/agentic-actions-auditor/references/vector-e-error-log-injection.md +88 -0
  87. package/skills/agentic-actions-auditor/references/vector-f-subshell-expansion.md +82 -0
  88. package/skills/agentic-actions-auditor/references/vector-g-eval-of-ai-output.md +91 -0
  89. package/skills/agentic-actions-auditor/references/vector-h-dangerous-sandbox-configs.md +102 -0
  90. package/skills/agentic-actions-auditor/references/vector-i-wildcard-allowlists.md +88 -0
  91. package/skills/audit/SKILL.md +562 -0
  92. package/skills/audit/assets/icon.svg +7 -0
  93. package/skills/audit/hooks/scripts/validate_phase_output.py +550 -0
  94. package/skills/audit/references/adversarial-review.md +148 -0
  95. package/skills/audit/references/architecture-aware-sast.md +306 -0
  96. package/skills/audit/references/audit-workflow.md +737 -0
  97. package/skills/audit/references/chamber-protocol.md +384 -0
  98. package/skills/audit/references/creative-attack-modes.md +221 -0
  99. package/skills/audit/references/deep-analysis.md +273 -0
  100. package/skills/audit/references/domain-attack-playbooks.md +1129 -0
  101. package/skills/audit/references/knowledge-base-template.md +513 -0
  102. package/skills/audit/references/real-env-validation.md +191 -0
  103. package/skills/audit/references/report-templates.md +417 -0
  104. package/skills/audit/references/triage-and-prereqs.md +134 -0
  105. package/skills/audit/scripts/consolidate_drafts.py +554 -0
  106. package/skills/audit/scripts/partition_findings.py +152 -0
  107. package/skills/audit/scripts/rg-hotspots.sh +121 -0
  108. package/skills/audit/scripts/stamp_file_state.py +349 -0
  109. package/skills/code-reviewer/SKILL.md +65 -0
  110. package/skills/codeql/SKILL.md +281 -0
  111. package/skills/codeql/references/build-fixes.md +90 -0
  112. package/skills/codeql/references/diagnostic-query-templates.md +339 -0
  113. package/skills/codeql/references/extension-yaml-format.md +209 -0
  114. package/skills/codeql/references/important-only-suite.md +153 -0
  115. package/skills/codeql/references/language-details.md +207 -0
  116. package/skills/codeql/references/macos-arm64e-workaround.md +179 -0
  117. package/skills/codeql/references/performance-tuning.md +111 -0
  118. package/skills/codeql/references/quality-assessment.md +172 -0
  119. package/skills/codeql/references/ruleset-catalog.md +63 -0
  120. package/skills/codeql/references/run-all-suite.md +92 -0
  121. package/skills/codeql/references/sarif-processing.md +79 -0
  122. package/skills/codeql/references/threat-models.md +51 -0
  123. package/skills/codeql/workflows/build-database.md +280 -0
  124. package/skills/codeql/workflows/create-data-extensions.md +261 -0
  125. package/skills/codeql/workflows/run-analysis.md +301 -0
  126. package/skills/differential-review/SKILL.md +220 -0
  127. package/skills/differential-review/adversarial.md +203 -0
  128. package/skills/differential-review/methodology.md +234 -0
  129. package/skills/differential-review/patterns.md +300 -0
  130. package/skills/differential-review/reporting.md +369 -0
  131. package/skills/fp-check/SKILL.md +125 -0
  132. package/skills/fp-check/references/bug-class-verification.md +114 -0
  133. package/skills/fp-check/references/deep-verification.md +143 -0
  134. package/skills/fp-check/references/evidence-templates.md +91 -0
  135. package/skills/fp-check/references/false-positive-patterns.md +115 -0
  136. package/skills/fp-check/references/gate-reviews.md +27 -0
  137. package/skills/fp-check/references/standard-verification.md +78 -0
  138. package/skills/insecure-defaults/SKILL.md +117 -0
  139. package/skills/insecure-defaults/references/examples.md +409 -0
  140. package/skills/last30days/SKILL.md +444 -0
  141. package/skills/sarif-parsing/SKILL.md +483 -0
  142. package/skills/sarif-parsing/resources/jq-queries.md +162 -0
  143. package/skills/sarif-parsing/resources/sarif_helpers.py +331 -0
  144. package/skills/security-threat-model/LICENSE.txt +201 -0
  145. package/skills/security-threat-model/SKILL.md +81 -0
  146. package/skills/security-threat-model/agents/openai.yaml +4 -0
  147. package/skills/security-threat-model/references/prompt-template.md +255 -0
  148. package/skills/security-threat-model/references/security-controls-and-assets.md +32 -0
  149. package/skills/semgrep/SKILL.md +212 -0
  150. package/skills/semgrep/references/rulesets.md +162 -0
  151. package/skills/semgrep/references/scan-modes.md +110 -0
  152. package/skills/semgrep/references/scanner-task-prompt.md +140 -0
  153. package/skills/semgrep/scripts/merge_sarif.py +203 -0
  154. package/skills/semgrep/workflows/scan-workflow.md +311 -0
  155. package/skills/semgrep-rule-creator/SKILL.md +168 -0
  156. package/skills/semgrep-rule-creator/references/quick-reference.md +202 -0
  157. package/skills/semgrep-rule-creator/references/workflow.md +240 -0
  158. package/skills/semgrep-rule-variant-creator/SKILL.md +205 -0
  159. package/skills/semgrep-rule-variant-creator/references/applicability-analysis.md +250 -0
  160. package/skills/semgrep-rule-variant-creator/references/language-syntax-guide.md +324 -0
  161. package/skills/semgrep-rule-variant-creator/references/workflow.md +518 -0
  162. package/skills/sharp-edges/SKILL.md +292 -0
  163. package/skills/sharp-edges/references/auth-patterns.md +252 -0
  164. package/skills/sharp-edges/references/case-studies.md +274 -0
  165. package/skills/sharp-edges/references/config-patterns.md +333 -0
  166. package/skills/sharp-edges/references/crypto-apis.md +190 -0
  167. package/skills/sharp-edges/references/lang-c.md +205 -0
  168. package/skills/sharp-edges/references/lang-csharp.md +285 -0
  169. package/skills/sharp-edges/references/lang-go.md +270 -0
  170. package/skills/sharp-edges/references/lang-java.md +263 -0
  171. package/skills/sharp-edges/references/lang-javascript.md +269 -0
  172. package/skills/sharp-edges/references/lang-kotlin.md +265 -0
  173. package/skills/sharp-edges/references/lang-php.md +245 -0
  174. package/skills/sharp-edges/references/lang-python.md +274 -0
  175. package/skills/sharp-edges/references/lang-ruby.md +273 -0
  176. package/skills/sharp-edges/references/lang-rust.md +272 -0
  177. package/skills/sharp-edges/references/lang-swift.md +287 -0
  178. package/skills/sharp-edges/references/language-specific.md +588 -0
  179. package/skills/spec-to-code-compliance/SKILL.md +357 -0
  180. package/skills/spec-to-code-compliance/resources/COMPLETENESS_CHECKLIST.md +69 -0
  181. package/skills/spec-to-code-compliance/resources/IR_EXAMPLES.md +417 -0
  182. package/skills/spec-to-code-compliance/resources/OUTPUT_REQUIREMENTS.md +105 -0
  183. package/skills/supply-chain-risk-auditor/SKILL.md +67 -0
  184. package/skills/supply-chain-risk-auditor/resources/results-template.md +41 -0
  185. package/skills/variant-analysis/METHODOLOGY.md +327 -0
  186. package/skills/variant-analysis/SKILL.md +142 -0
  187. package/skills/variant-analysis/resources/codeql/cpp.ql +119 -0
  188. package/skills/variant-analysis/resources/codeql/go.ql +69 -0
  189. package/skills/variant-analysis/resources/codeql/java.ql +71 -0
  190. package/skills/variant-analysis/resources/codeql/javascript.ql +63 -0
  191. package/skills/variant-analysis/resources/codeql/python.ql +80 -0
  192. package/skills/variant-analysis/resources/semgrep/cpp.yaml +98 -0
  193. package/skills/variant-analysis/resources/semgrep/go.yaml +63 -0
  194. package/skills/variant-analysis/resources/semgrep/java.yaml +61 -0
  195. package/skills/variant-analysis/resources/semgrep/javascript.yaml +60 -0
  196. package/skills/variant-analysis/resources/semgrep/python.yaml +72 -0
  197. package/skills/variant-analysis/resources/variant-report-template.md +75 -0
  198. package/skills/vuln-report/SKILL.md +137 -0
  199. package/skills/vuln-report/agents/openai.yaml +4 -0
  200. package/skills/vuln-report/references/report-template.md +135 -0
  201. package/skills/wooyun-legacy/SKILL.md +367 -0
  202. package/skills/wooyun-legacy/references/bank-penetration.md +222 -0
  203. package/skills/wooyun-legacy/references/checklists/command-execution-checklist.md +119 -0
  204. package/skills/wooyun-legacy/references/checklists/csrf-checklist.md +74 -0
  205. package/skills/wooyun-legacy/references/checklists/file-upload-checklist.md +108 -0
  206. package/skills/wooyun-legacy/references/checklists/info-disclosure-checklist.md +114 -0
  207. package/skills/wooyun-legacy/references/checklists/logic-flaws-checklist.md +95 -0
  208. package/skills/wooyun-legacy/references/checklists/misconfig-checklist.md +124 -0
  209. package/skills/wooyun-legacy/references/checklists/path-traversal-checklist.md +87 -0
  210. package/skills/wooyun-legacy/references/checklists/rce-checklist.md +93 -0
  211. package/skills/wooyun-legacy/references/checklists/sql-injection-checklist.md +97 -0
  212. package/skills/wooyun-legacy/references/checklists/ssrf-checklist.md +99 -0
  213. package/skills/wooyun-legacy/references/checklists/unauthorized-access-checklist.md +89 -0
  214. package/skills/wooyun-legacy/references/checklists/weak-password-checklist.md +115 -0
  215. package/skills/wooyun-legacy/references/checklists/xss-checklist.md +103 -0
  216. package/skills/wooyun-legacy/references/checklists/xxe-checklist.md +130 -0
  217. package/skills/wooyun-legacy/references/info-disclosure.md +975 -0
  218. package/skills/wooyun-legacy/references/logic-flaws.md +721 -0
  219. package/skills/wooyun-legacy/references/path-traversal.md +1191 -0
  220. package/skills/wooyun-legacy/references/telecom-penetration.md +156 -0
  221. package/skills/wooyun-legacy/references/unauthorized-access.md +980 -0
  222. package/skills/wooyun-legacy/references/xss.md +746 -0
  223. package/skills/zeroize-audit/SKILL.md +371 -0
  224. package/skills/zeroize-audit/configs/c.yaml +21 -0
  225. package/skills/zeroize-audit/configs/default.yaml +128 -0
  226. package/skills/zeroize-audit/configs/rust.yaml +83 -0
  227. package/skills/zeroize-audit/prompts/report_template.md +238 -0
  228. package/skills/zeroize-audit/prompts/system.md +163 -0
  229. package/skills/zeroize-audit/prompts/task.md +97 -0
  230. package/skills/zeroize-audit/references/compile-commands.md +231 -0
  231. package/skills/zeroize-audit/references/detection-strategy.md +191 -0
  232. package/skills/zeroize-audit/references/ir-analysis.md +252 -0
  233. package/skills/zeroize-audit/references/mcp-analysis.md +221 -0
  234. package/skills/zeroize-audit/references/poc-generation.md +470 -0
  235. package/skills/zeroize-audit/references/rust-zeroization-patterns.md +867 -0
  236. package/skills/zeroize-audit/schemas/input.json +83 -0
  237. package/skills/zeroize-audit/schemas/output.json +140 -0
  238. package/skills/zeroize-audit/tools/analyze_asm.sh +202 -0
  239. package/skills/zeroize-audit/tools/analyze_cfg.py +381 -0
  240. package/skills/zeroize-audit/tools/analyze_heap.sh +211 -0
  241. package/skills/zeroize-audit/tools/analyze_ir_semantic.py +429 -0
  242. package/skills/zeroize-audit/tools/diff_ir.sh +135 -0
  243. package/skills/zeroize-audit/tools/diff_rust_mir.sh +189 -0
  244. package/skills/zeroize-audit/tools/emit_asm.sh +67 -0
  245. package/skills/zeroize-audit/tools/emit_ir.sh +77 -0
  246. package/skills/zeroize-audit/tools/emit_rust_asm.sh +178 -0
  247. package/skills/zeroize-audit/tools/emit_rust_ir.sh +150 -0
  248. package/skills/zeroize-audit/tools/emit_rust_mir.sh +158 -0
  249. package/skills/zeroize-audit/tools/extract_compile_flags.py +284 -0
  250. package/skills/zeroize-audit/tools/generate_poc.py +1329 -0
  251. package/skills/zeroize-audit/tools/mcp/apply_confidence_gates.py +113 -0
  252. package/skills/zeroize-audit/tools/mcp/check_mcp.sh +68 -0
  253. package/skills/zeroize-audit/tools/mcp/normalize_mcp_evidence.py +125 -0
  254. package/skills/zeroize-audit/tools/scripts/check_llvm_patterns.py +481 -0
  255. package/skills/zeroize-audit/tools/scripts/check_mir_patterns.py +554 -0
  256. package/skills/zeroize-audit/tools/scripts/check_rust_asm.py +424 -0
  257. package/skills/zeroize-audit/tools/scripts/check_rust_asm_aarch64.py +300 -0
  258. package/skills/zeroize-audit/tools/scripts/check_rust_asm_x86.py +283 -0
  259. package/skills/zeroize-audit/tools/scripts/find_dangerous_apis.py +375 -0
  260. package/skills/zeroize-audit/tools/scripts/semantic_audit.py +923 -0
  261. package/skills/zeroize-audit/tools/track_dataflow.sh +196 -0
  262. package/skills/zeroize-audit/tools/validate_rust_toolchain.sh +298 -0
  263. package/skills/zeroize-audit/workflows/phase-0-preflight.md +150 -0
  264. package/skills/zeroize-audit/workflows/phase-1-source-analysis.md +144 -0
  265. package/skills/zeroize-audit/workflows/phase-2-compiler-analysis.md +139 -0
  266. package/skills/zeroize-audit/workflows/phase-3-interim-report.md +46 -0
  267. package/skills/zeroize-audit/workflows/phase-4-poc-generation.md +46 -0
  268. package/skills/zeroize-audit/workflows/phase-5-poc-validation.md +136 -0
  269. package/skills/zeroize-audit/workflows/phase-6-final-report.md +44 -0
  270. package/skills/zeroize-audit/workflows/phase-7-test-generation.md +42 -0
  271. package/themes/piolium-srcery.json +94 -0
@@ -0,0 +1,238 @@
1
+ # Zeroize Audit Report
2
+
3
+ **Run ID:** `<run_id>`
4
+ **Timestamp:** `<ISO-8601>`
5
+ **Repository:** `<path>`
6
+ **Compile DB:** `<compile_db>`
7
+
8
+ **Configuration:**
9
+ | Setting | Value |
10
+ |---|---|
11
+ | Optimization levels | O0, O1, O2 |
12
+ | MCP mode | prefer |
13
+ | MCP available | yes / no |
14
+ | Assembly analysis | enabled / disabled |
15
+ | Semantic IR analysis | enabled / disabled |
16
+ | CFG analysis | enabled / disabled |
17
+ | Runtime tests | enabled / disabled |
18
+ | PoC validation | mandatory |
19
+
20
+ ---
21
+
22
+ ## Executive Summary
23
+
24
+ | Metric | Count |
25
+ |---|---|
26
+ | Files scanned | 0 |
27
+ | Translation units analyzed | 0 |
28
+ | **Total findings** | **0** |
29
+
30
+ ### By Severity
31
+
32
+ | Severity | Count |
33
+ |---|---|
34
+ | High | 0 |
35
+ | Medium | 0 |
36
+
37
+ ### By Confidence
38
+
39
+ | Confidence | Count |
40
+ |---|---|
41
+ | Confirmed | 0 |
42
+ | Likely | 0 |
43
+ | Needs review | 0 |
44
+
45
+ ### PoC Validation
46
+
47
+ | Metric | Count |
48
+ |---|---|
49
+ | PoCs generated | 0 |
50
+ | PoCs validated | 0 |
51
+ | Exploitable (confirmed) | 0 |
52
+ | Not exploitable | 0 |
53
+ | Compile failures | 0 |
54
+ | No PoC generated | 0 |
55
+
56
+ ### By Category
57
+
58
+ | Category | Count |
59
+ |---|---|
60
+ | MISSING_SOURCE_ZEROIZE | 0 |
61
+ | PARTIAL_WIPE | 0 |
62
+ | NOT_ON_ALL_PATHS | 0 |
63
+ | OPTIMIZED_AWAY_ZEROIZE | 0 |
64
+ | SECRET_COPY | 0 |
65
+ | INSECURE_HEAP_ALLOC | 0 |
66
+ | STACK_RETENTION | 0 |
67
+ | REGISTER_SPILL | 0 |
68
+ | MISSING_ON_ERROR_PATH | 0 |
69
+ | NOT_DOMINATING_EXITS | 0 |
70
+ | LOOP_UNROLLED_INCOMPLETE | 0 |
71
+
72
+ ---
73
+
74
+ ## Sensitive Objects Inventory
75
+
76
+ | ID | Name | Type | Location | Confidence | Heuristic | Has Wipe |
77
+ |---|---|---|---|---|---|---|
78
+ | SO-0001 | key | uint8_t[32] | path/to/file.c:45 | low | name pattern | no |
79
+ | SO-0002 | session_key | uint8_t[16] | path/to/file.c:89 | medium | type hint | yes |
80
+
81
+ ---
82
+
83
+ ## Findings
84
+
85
+ ### High Severity
86
+
87
+ #### ZA-0002: STACK_RETENTION — high (confirmed)
88
+
89
+ **Location:** `path/to/file.c:89`
90
+ **Object:** `secret_function` (`stack_frame`, 192 bytes)
91
+
92
+ **Evidence:**
93
+ - [asm] Stack frame (192 bytes) allocated at function entry; no red-zone clearing before ret at line 112.
94
+ - [asm] `sub $0xc0, %rsp` at entry; no corresponding zeroing sequence before ret.
95
+
96
+ **Compiler Evidence:**
97
+ - Opt levels analyzed: O0, O2
98
+ - O2: Stack allocated 192 bytes; ret reached without clearing red-zone below %rsp.
99
+ - **Summary:** Stack frame persists with uncleared secret bytes after function return.
100
+
101
+ **Recommended Fix:**
102
+ Add `explicit_bzero()` across the full stack frame, or use a compiler barrier and volatile wipe loop covering the red-zone.
103
+
104
+ ---
105
+
106
+ #### ZA-0003: REGISTER_SPILL — high (confirmed)
107
+
108
+ **Location:** `path/to/file.c:156`
109
+ **Object:** `encrypt` (`stack_slot`, 8 bytes)
110
+
111
+ **Evidence:**
112
+ - [asm] `movq %r12, -48(%rsp)` at line 156 spills key fragment to stack; no corresponding zero-store before ret.
113
+
114
+ **Compiler Evidence:**
115
+ - Opt levels analyzed: O0, O2
116
+ - O2: `movq %r12, -48(%rsp)` without corresponding cleanup of spill slot.
117
+ - **Summary:** Register spill at -48(%rsp) contains key fragment; slot not cleared before return.
118
+
119
+ **Recommended Fix:**
120
+ Use inline assembly with register constraints to prevent spilling, or add explicit zero-store covering the spill slot before return.
121
+
122
+ ---
123
+
124
+ #### ZA-0005: INSECURE_HEAP_ALLOC — high (confirmed)
125
+
126
+ **Location:** `path/to/file.c:67`
127
+ **Object:** `private_key` (`uint8_t *`)
128
+
129
+ **Evidence:**
130
+ - [source] `malloc()` at line 67 allocates buffer for `private_key`. No `mlock()` or `madvise(MADV_DONTDUMP)` found for this allocation.
131
+
132
+ **Recommended Fix:**
133
+ Replace `malloc()` with `OPENSSL_secure_malloc()` or `sodium_malloc()`. Add `mlock()` and `madvise(MADV_DONTDUMP)` if using standard allocator.
134
+
135
+ ---
136
+
137
+ ### Medium Severity
138
+
139
+ #### ZA-0001: MISSING_SOURCE_ZEROIZE — medium (likely)
140
+
141
+ **Location:** `path/to/file.c:123`
142
+ **Object:** `key` (`uint8_t[32]`, 32 bytes)
143
+
144
+ **Evidence:**
145
+ - [source] Sensitive buffer `key` matches name pattern; no approved wipe call found before return at line 130.
146
+
147
+ **Recommended Fix:**
148
+ Use `explicit_bzero(key, sizeof(key))` on all exit paths.
149
+
150
+ ---
151
+
152
+ #### ZA-0006: OPTIMIZED_AWAY_ZEROIZE — medium (confirmed)
153
+
154
+ **Location:** `path/to/file.c:88`
155
+ **Object:** `nonce` (`uint8_t[12]`, 12 bytes)
156
+
157
+ **Evidence:**
158
+ - [ir] O0 IR contains `llvm.memset` call zeroing `nonce` at line 88; absent in O1 IR — dead-store elimination.
159
+
160
+ **Compiler Evidence:**
161
+ - Opt levels analyzed: O0, O1, O2
162
+ - O0: `llvm.memset(nonce, 0, 12)` present at line 88.
163
+ - O1: `llvm.memset` call removed — dead store eliminated.
164
+ - O2: `llvm.memset` call absent.
165
+ - **Summary:** Wipe disappears at O1; cause: dead-store elimination of memset with no subsequent read.
166
+
167
+ **Recommended Fix:**
168
+ Replace `memset()` with `explicit_bzero()` or add a volatile compiler barrier after the wipe to prevent elimination.
169
+
170
+ ---
171
+
172
+ ### Needs Review
173
+
174
+ #### ZA-0004: SECRET_COPY — high (needs_review)
175
+
176
+ **Location:** `path/to/file.c:203`
177
+ **Object:** `session_key` (`uint8_t[16]`, 16 bytes)
178
+
179
+ **Evidence:**
180
+ - [source] `memcpy()` at line 203 copies `session_key` to `tmp_key` (line 199). No approved wipe tracked for destination `tmp_key` before it goes out of scope at line 218.
181
+
182
+ **Recommended Fix:**
183
+ Ensure both `session_key` and `tmp_key` are zeroized on all exit paths using `explicit_bzero()`.
184
+
185
+ ---
186
+
187
+ ## PoC Validation Results
188
+
189
+ | Finding | Category | PoC File | Exit Code | Result | Impact |
190
+ |---|---|---|---|---|---|
191
+ | ZA-0001 | MISSING_SOURCE_ZEROIZE | poc_za_0001_missing_source_zeroize.c | 0 | exploitable | Confirmed |
192
+ | ZA-0002 | STACK_RETENTION | poc_za_0002_stack_retention.c | 1 | not_exploitable | Downgraded to low (informational) |
193
+ | ZA-0003 | REGISTER_SPILL | poc_za_0003_register_spill.c | — | compile_failure | No change |
194
+
195
+ ---
196
+
197
+ ## Superseded Findings
198
+
199
+ _No findings were superseded in this run._
200
+
201
+ <!-- Example:
202
+ | Superseded | Superseded By | Reason |
203
+ |---|---|---|
204
+ | F-SRC-0005 (NOT_ON_ALL_PATHS) | ZA-0007 / F-CFG-a1b2-0003 (NOT_DOMINATING_EXITS) | CFG dominance analysis provides definitive result |
205
+ -->
206
+
207
+ ---
208
+
209
+ ## Confidence Gate Summary
210
+
211
+ | Finding | Action | Reason |
212
+ |---|---|---|
213
+ | ZA-0004 (SECRET_COPY) | Downgraded to needs_review | MCP unavailable; only 1 non-MCP signal (source pattern match) |
214
+
215
+ ---
216
+
217
+ ## Analysis Coverage
218
+
219
+ | Metric | Value |
220
+ |---|---|
221
+ | TUs in compile DB | 0 |
222
+ | TUs analyzed | 0 |
223
+ | TUs with sensitive objects | 0 |
224
+ | Agent 1 (MCP resolver) | success / skipped / failed |
225
+ | Agent 2 (source analyzer) | success / failed |
226
+ | Agent 3 (compiler analyzer) | N/N TUs succeeded |
227
+ | Agent 4 (report assembler) | success |
228
+ | Agent 5 (PoC generator) | success / failed |
229
+ | Agent 6 (test generator) | success / skipped / failed |
230
+
231
+ ---
232
+
233
+ ## Appendix: Evidence Files
234
+
235
+ | Finding | Evidence File | Description |
236
+ |---|---|---|
237
+ | ZA-0002 | `compiler-analysis/a1b2/asm-findings.json` | Assembly analysis output |
238
+ | ZA-0006 | `compiler-analysis/c3d4/ir-findings.json` | IR diff analysis output |
@@ -0,0 +1,163 @@
1
+ # zeroize-audit (Claude Skill)
2
+
3
+ Audits C/C++/Rust code for missing zeroization and compiler-removed wipes.
4
+ Pipeline: source scan -> MCP/LSP semantic context -> IR diff -> assembly checks.
5
+
6
+ ## Findings
7
+
8
+ - `MISSING_SOURCE_ZEROIZE`, `PARTIAL_WIPE`, `NOT_ON_ALL_PATHS`
9
+ - `OPTIMIZED_AWAY_ZEROIZE` (IR evidence required)
10
+ - `REGISTER_SPILL`, `STACK_RETENTION` (assembly evidence for C/C++; LLVM IR evidence for Rust; assembly corroboration available for Rust via `check_rust_asm.py`)
11
+ - `SECRET_COPY`, `INSECURE_HEAP_ALLOC`
12
+ - `MISSING_ON_ERROR_PATH`, `NOT_DOMINATING_EXITS`, `LOOP_UNROLLED_INCOMPLETE`
13
+
14
+ ## Working Directory
15
+
16
+ Each run creates a working directory at `/tmp/zeroize-audit-{run_id}/` with the following structure. Agents write persistent finding files here; later agents and the orchestrator reconstruct the full picture from these files without relying on conversation history.
17
+
18
+ ```
19
+ /tmp/zeroize-audit-{run_id}/
20
+ preflight.json # Orchestrator: env, config, TU list
21
+ mcp-evidence/
22
+ status.json # MCP resolver status (success/partial/fail)
23
+ symbols.json # Resolved symbol definitions + types
24
+ references.json # Cross-file reference graph
25
+ notes.md # MCP observations + cross-refs
26
+ source-analysis/
27
+ sensitive-objects.json # C/C++ SO-NNNN + Rust SO-NNNN (shared, appended by each source-analyzer)
28
+ source-findings.json # F-SRC-NNNN (C/C++) + F-RUST-SRC-NNNN (Rust, appended)
29
+ tu-map.json # C/C++ TU hashes + Rust crate hash
30
+ rust-semantic-findings.json # Intermediate: 2b-rust-source-analyzer rustdoc output
31
+ rust-dangerous-api-findings.json # Intermediate: 2b-rust-source-analyzer grep output
32
+ rust-notes.md # 2b-rust-source-analyzer notes
33
+ notes.md # 2-source-analyzer observations
34
+ rust-compiler-analysis/
35
+ {rust_tu_hash}.mir # MIR text (emit_rust_mir.sh; supports --opt, --bin/--lib)
36
+ {rust_tu_hash}.O0.ll # LLVM IR at O0 (emit_rust_ir.sh; supports --bin/--lib)
37
+ {rust_tu_hash}.O2.ll # LLVM IR at O2 (emit_rust_ir.sh; supports --bin/--lib)
38
+ {rust_tu_hash}.O2.s # Assembly at O2 (emit_rust_asm.sh; only if enable_asm=true)
39
+ mir-findings.json # F-RUST-MIR-NNNN IDs
40
+ ir-findings.json # F-RUST-IR-NNNN IDs
41
+ asm-findings.json # F-RUST-ASM-NNNN IDs (empty array if enable_asm=false)
42
+ notes.md
43
+ compiler-analysis/
44
+ {tu_hash}/
45
+ ir-findings.json # F-IR-{tu_hash}-NNNN IDs
46
+ asm-findings.json # F-ASM-{tu_hash}-NNNN IDs
47
+ cfg-findings.json # F-CFG-{tu_hash}-NNNN IDs
48
+ semantic-ir.json # F-SIR-{tu_hash}-NNNN IDs
49
+ superseded-findings.json # CFG results that replace heuristic source findings
50
+ notes.md
51
+ report/
52
+ raw-findings.json # All findings pre-gating
53
+ id-mapping.json # Namespaced IDs -> final ZA-NNNN IDs
54
+ findings.json # Gated findings (structured JSON for downstream tools)
55
+ final-report.md # Comprehensive markdown report (primary output)
56
+ notes.md
57
+ poc/ # PoC files, manifest, validation/verification results, notes.md
58
+ poc_manifest.json # Generated by agent 5
59
+ poc_validation_results.json # Written by agent 5b (compile/run results)
60
+ poc_verification.json # Written by agent 5c (semantic verification)
61
+ poc_final_results.json # Written by orchestrator Phase 5 (merged results)
62
+ tests/ # Test harnesses, Makefile, notes.md
63
+ ```
64
+
65
+ ## Cross-Reference Convention
66
+
67
+ IDs are namespaced per agent to prevent collisions during parallel execution:
68
+
69
+ | Entity | Pattern | Assigned By |
70
+ |---|---|---|
71
+ | Sensitive object (C/C++) | `SO-NNNN` | `2-source-analyzer` |
72
+ | Sensitive object (Rust) | `SO-NNNN` (offset 5000+) | `2b-rust-source-analyzer` |
73
+ | Source finding (C/C++) | `F-SRC-NNNN` | `2-source-analyzer` |
74
+ | Source finding (Rust) | `F-RUST-SRC-NNNN` | `2b-rust-source-analyzer` |
75
+ | IR finding (C/C++) | `F-IR-{tu_hash}-NNNN` | `3-tu-compiler-analyzer` |
76
+ | ASM finding | `F-ASM-{tu_hash}-NNNN` | `3-tu-compiler-analyzer` |
77
+ | CFG finding | `F-CFG-{tu_hash}-NNNN` | `3-tu-compiler-analyzer` |
78
+ | Semantic IR finding | `F-SIR-{tu_hash}-NNNN` | `3-tu-compiler-analyzer` |
79
+ | Rust MIR finding | `F-RUST-MIR-NNNN` | `3b-rust-compiler-analyzer` |
80
+ | Rust LLVM IR finding | `F-RUST-IR-NNNN` | `3b-rust-compiler-analyzer` |
81
+ | Rust assembly finding | `F-RUST-ASM-NNNN` | `3b-rust-compiler-analyzer` |
82
+ | Translation unit | `TU-{hash}` | Orchestrator |
83
+ | Final finding | `ZA-NNNN` | `4-report-composer` |
84
+
85
+ Every finding JSON object includes:
86
+ - `related_objects`: `["SO-0003"]` — which sensitive objects this applies to
87
+ - `related_findings`: `["F-SRC-0001"]` — related findings in other files
88
+ - `evidence_files`: `["compiler-analysis/a1b2/ir-diff-O0-O2.txt"]` — paths relative to workdir
89
+
90
+ ## Dual-Mode Report Assembly
91
+
92
+ Agent `4-report-composer` is invoked twice during a run:
93
+ 1. **Interim mode** (Phase 3): Collects findings, applies supersessions and confidence gates, produces `findings.json` only. No `final-report.md` at this stage.
94
+ 2. **Final mode** (Phase 6): Reads existing `findings.json`, merges PoC validation and verification results from `poc/poc_final_results.json`, then produces both an updated `findings.json` and the final `final-report.md`.
95
+
96
+ ## Agent Error Protocol
97
+
98
+ - **Always write output files**: Every agent must write its status/output JSON files even on failure (use empty arrays `[]` or error status objects).
99
+ - **Prefer partial results over nothing**: If one sub-step fails (e.g., ASM analysis), write results from completed steps and continue.
100
+ - **Notes.md is mandatory**: Every agent writes a `notes.md` summarizing what it did, any errors, and relative paths to its output files.
101
+ - **Temp file cleanup**: Agents must clean up `/tmp/zeroize-audit/<tu_hash>.*` temp files on completion or failure.
102
+
103
+ ## Prerequisites
104
+
105
+ **C/C++ analysis:**
106
+ - `compile_commands.json` is mandatory.
107
+ - Codebase must be buildable with commands from the compile DB.
108
+ - Required tools: `clang`, `uvx` (for Serena MCP server), `python3`.
109
+
110
+ **Rust analysis:**
111
+ - `Cargo.toml` path is mandatory.
112
+ - Crate must be buildable (`cargo check` passes).
113
+ - Required tools: `cargo +nightly`, `uv`.
114
+
115
+ Quick check:
116
+ ```bash
117
+ which clang uvx python3 # C/C++
118
+ cargo +nightly --version # Rust
119
+ uv --version # Rust Python scripts
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Rust Analysis — Few-Shot Examples
125
+
126
+ ### Example 1 — Copy derive on sensitive type → SECRET_COPY (critical)
127
+
128
+ ```rust
129
+ #[derive(Copy, Clone)]
130
+ struct HmacKey([u8; 32]);
131
+ ```
132
+
133
+ Finding: `SECRET_COPY` (critical). `#[derive(Copy)]` on `HmacKey` — all assignments are untracked duplicates, no Drop ever runs. Every `let k2 = k1` silently copies all 32 key bytes with no automatic cleanup.
134
+
135
+ Fix: Remove `Copy`. Add `#[derive(ZeroizeOnDrop)]` from the `zeroize` crate.
136
+
137
+ ### Example 2 — mem::forget on secret → MISSING_SOURCE_ZEROIZE (critical)
138
+
139
+ ```rust
140
+ let key = SecretKey::new();
141
+ // ... use key ...
142
+ std::mem::forget(key); // BAD: prevents Drop / ZeroizeOnDrop
143
+ ```
144
+
145
+ Finding: `MISSING_SOURCE_ZEROIZE` (critical). `mem::forget()` prevents `Drop` and `ZeroizeOnDrop` from running — secret bytes remain in memory indefinitely.
146
+
147
+ Fix: Remove `mem::forget`. Let the value drop normally, or call `key.zeroize()` before the forget if explicit timing is required.
148
+
149
+ ### Example 3 — Non-volatile memset removed at O2 → OPTIMIZED_AWAY_ZEROIZE (high)
150
+
151
+ At O0 LLVM IR:
152
+ ```llvm
153
+ store volatile i8 0, ptr %key_buf ; 32 volatile stores present
154
+ ```
155
+
156
+ At O2 LLVM IR:
157
+ ```llvm
158
+ ; stores absent — LLVM DSE removed them (key_buf never read after)
159
+ ```
160
+
161
+ Finding: `OPTIMIZED_AWAY_ZEROIZE` (high). Volatile store count dropped from 32 (O0) to 0 (O2). Dead-store elimination removed the wipe.
162
+
163
+ Fix: Use `zeroize::Zeroize::zeroize(&mut key_buf)` which emits a compiler-fence-backed wipe that survives DSE.
@@ -0,0 +1,97 @@
1
+ Task: Run zeroize-audit.
2
+
3
+ Inputs:
4
+ - path: {{path}}
5
+ - compile_db: {{compile_db}}
6
+ - cargo_manifest: {{cargo_manifest}}
7
+ - config: {{config}}
8
+ - opt_levels: {{opt_levels}}
9
+ - languages: {{languages}}
10
+ - max_tus: {{max_tus}}
11
+ - mcp_mode: {{mcp_mode}}
12
+ - mcp_required_for_advanced: {{mcp_required_for_advanced}}
13
+ - mcp_timeout_ms: {{mcp_timeout_ms}}
14
+ - enable_semantic_ir: {{enable_semantic_ir}}
15
+ - enable_cfg: {{enable_cfg}}
16
+ - enable_runtime_tests: {{enable_runtime_tests}}
17
+ - enable_asm: {{enable_asm}}
18
+ - poc_categories: {{poc_categories}}
19
+ - poc_output_dir: {{poc_output_dir}}
20
+
21
+ ---
22
+
23
+ ## Execution Protocol
24
+
25
+ ### Recovery
26
+
27
+ If a `workdir` is known from prior context, read `{workdir}/orchestrator-state.json` to recover state after context compression:
28
+
29
+ - `current_phase`: resume from this phase
30
+ - `workdir`, `run_id`: working directory and run identifier
31
+ - `inputs`: original input values
32
+ - `routing`: key booleans (`mcp_available`, `tu_count`, `finding_count`)
33
+ - `phases`: completion status and output file paths for each phase
34
+ - `key_file_paths`: paths to all inter-phase artifacts
35
+
36
+ If no state exists, start at Phase 0.
37
+
38
+ ### Phase Loop
39
+
40
+ Execute phases sequentially. Before each phase, read its workflow file from `{baseDir}/workflows/phase-{N}-{name}.md`. Follow the workflow's Preconditions, Instructions, State Update, and Error Handling sections.
41
+
42
+ | Phase | Workflow File | Skip Condition |
43
+ |---|---|---|
44
+ | 0 | `phase-0-preflight.md` | Never |
45
+ | 1 | `phase-1-source-analysis.md` | Never |
46
+ | 2 | `phase-2-compiler-analysis.md` | No sensitive objects (`tu-map.json` empty) |
47
+ | 3 | `phase-3-interim-report.md` | No sensitive objects |
48
+ | 4 | `phase-4-poc-generation.md` | Zero findings in interim report |
49
+ | 5 | `phase-5-poc-validation.md` | Zero findings or no PoCs generated |
50
+ | 6 | `phase-6-final-report.md` | Never (always produce a report) |
51
+ | 7 | `phase-7-test-generation.md` | `enable_runtime_tests=false` or zero findings |
52
+
53
+ ### Early Termination
54
+
55
+ Skip directly to Phase 6 (produce empty/partial report) when:
56
+
57
+ - Phase 1 source analyzer finds zero sensitive objects
58
+ - Phase 3 interim report contains zero findings
59
+
60
+ ### Phase 8 — Return Results (inline)
61
+
62
+ Read `{workdir}/report/final-report.md` and return its contents as the skill output.
63
+
64
+ The markdown report is the primary human-readable output. It contains:
65
+ - Executive summary with finding counts by severity, confidence, and category
66
+ - PoC validation summary with exploitable/not-exploitable counts
67
+ - Sensitive objects inventory
68
+ - Detailed findings grouped by severity and confidence, each with evidence, PoC validation result, and recommended fix
69
+ - Superseded findings and confidence gate summary
70
+ - Analysis coverage and evidence file appendix
71
+
72
+ The structured `{workdir}/report/findings.json` (matching `{baseDir}/schemas/output.json`) is also available for machine consumption.
73
+
74
+ ---
75
+
76
+ ## Error Handling Summary
77
+
78
+ | Failure | Behavior |
79
+ |---|---|
80
+ | Preflight fails (Phase 0) | Stop immediately, report failure |
81
+ | Config load fails (Phase 0) | Stop immediately |
82
+ | PoC generator agent fails (Phase 4) | Surface error to user — PoC generation is mandatory |
83
+ | MCP resolver fails + `mcp_mode=require` | Stop immediately (C/C++ only) |
84
+ | MCP resolver fails + `mcp_mode=prefer` | Continue with `mcp_available=false` (C/C++ only) |
85
+ | Source analyzer (C/C++) fails | Stop C/C++ analysis — no sensitive object list for C/C++ TUs |
86
+ | Rust source analyzer fails | Stop Rust analysis — log failure, continue if C/C++ analysis is also running |
87
+ | No sensitive objects found | Skip Phases 2–5, jump to Phase 6 for empty report |
88
+ | One TU compiler-analyzer fails | Continue with remaining TUs |
89
+ | All TU compiler-analyzers fail | Report assembler produces source-only report |
90
+ | Rust compiler analyzer (Wave 3R) fails | Log failure, continue — report assembler handles missing rust-compiler-analysis/ |
91
+ | `cargo +nightly` not available (Rust preflight) | Stop the run — nightly is required for MIR/IR emission |
92
+ | Python script missing (Rust preflight) | Warn and skip that sub-step — do not fail the run |
93
+ | Report assembler fails (interim) | Surface error to user |
94
+ | PoC generator fails | Pipeline stalls — cannot proceed to validation. Surface error to user |
95
+ | PoC compilation failure | Record in validation results, continue with other PoCs |
96
+ | Report assembler fails (final) | Surface error to user |
97
+ | Test generator fails | Report is still available without tests |