@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,148 @@
1
+ # Adversarial Review Methodology (P11-LITE Cold Verification)
2
+
3
+ Protocol for the Phase 11 Stage 2 cold verification agent. Under the Review Chamber model,
4
+ the Devil's Advocate already challenged every finding during the Phase 10 debate. Stage 2 is
5
+ therefore **scoped to CRITICAL and HIGH findings only** — Medium findings skip Stage 2 entirely.
6
+
7
+ ## Purpose
8
+
9
+ The Devil's Advocate challenges findings while the debate context is hot, but shares the
10
+ chamber's context window with other agents. Cold verification breaks any residual confirmation
11
+ bias by spawning a fresh agent with no access to the chamber debate, forcing fully independent
12
+ re-derivation. This is reserved for the highest-severity findings where the cost of a false
13
+ positive or missed vulnerability is greatest.
14
+
15
+ ## Isolation Rules
16
+
17
+ The adversarial reviewer agent receives **only**:
18
+ - The finding draft file path (`archon/findings-draft/<phase>-<NNN>-<slug>.md`)
19
+
20
+ The adversarial reviewer MUST NOT:
21
+ - Read Phase 10 working notes or intermediate analysis files
22
+ - Read the original agent's conversation history or reasoning chain
23
+ - Read any file in `archon/` other than the single finding draft it was given
24
+ - Be told what the finding agent concluded — only what the finding draft states
25
+
26
+ The agent spawner must construct the task description from only the finding draft path. Do not include summaries, context, or the finding agent's reasoning.
27
+
28
+ ---
29
+
30
+ ## Step 1 — Restate and Decompose
31
+
32
+ Read only the finding draft. Restate the vulnerability claim in your own words without copying the original description. Then decompose into testable sub-claims:
33
+
34
+ - Sub-claim A: Attacker controls input X
35
+ - Sub-claim B: Input X reaches code point Y without adequate sanitization
36
+ - Sub-claim C: Code point Y causes security effect Z
37
+
38
+ If any sub-claim is incoherent, logically impossible, or unsupported by the draft, record `Sub-claim failure: <which sub-claim and why>` and proceed to the verdict with DISPROVED.
39
+
40
+ ---
41
+
42
+ ## Step 2 — Independent Code Path Trace
43
+
44
+ Starting from the entry point stated in the finding draft, trace the code path to the claimed sink independently. Do not rely on the finding draft's code snippets as a guide — trace from source yourself.
45
+
46
+ Document:
47
+ - Every validation or sanitization function encountered on the path
48
+ - Every transformation applied to the input
49
+ - Whether each control is bypassable given realistic attacker input
50
+ - Framework-level protections active on this path (ORM, auto-escaping, CSRF tokens, etc.)
51
+
52
+ If the code path cannot be traced as described, record the discrepancy.
53
+
54
+ ---
55
+
56
+ ## Step 3 — Protection Surface Search
57
+
58
+ Actively search for controls that could block or mitigate the claimed attack. Check each layer:
59
+
60
+ | Layer | What to Look For |
61
+ |-------|-----------------|
62
+ | Language-level | Type system enforcement, memory safety, bounds checking |
63
+ | Framework-level | ORM parameterization, template auto-escaping, CSRF middleware, input validation decorators |
64
+ | Middleware | WAF rules, proxy normalization, rate limiting, authentication enforcement |
65
+ | Application-level | Allowlists, ownership checks, role verification, input length limits |
66
+ | Documentation-level | `SECURITY.md`, changelogs, `CONTRIBUTING.md` — does the project explicitly accept this as a known risk? |
67
+
68
+ Record each protection found and assess whether it blocks the claimed attack path.
69
+
70
+ ---
71
+
72
+ ## Step 4 — Real-Environment Reproduction
73
+
74
+ Follow the procedures in `real-env-validation.md`. Provision an appropriate environment for the project type and attempt reproduction.
75
+
76
+ Required:
77
+ - Deploy at the same commit referenced in the finding draft
78
+ - Verify the environment is working normally (healthcheck) before attempting exploitation
79
+ - Attempt the reproduction steps from the finding draft exactly as written
80
+ - If the first attempt fails, try up to 3 variations
81
+
82
+ Record:
83
+ - Environment type and provisioning commands used
84
+ - Healthcheck result
85
+ - Each attempt and its outcome
86
+ - Evidence files stored in `archon/real-env-evidence/<slug>/`
87
+
88
+ If real-environment reproduction is blocked (see `real-env-validation.md`), document the blocker and continue to Steps 5-7 based on code analysis only. Annotate `PoC-Status: theoretical`.
89
+
90
+ ---
91
+
92
+ ## Step 5 — Prosecution and Defense Briefs
93
+
94
+ Write two independent arguments. Each must cite specific code locations and evidence from Steps 2-4.
95
+
96
+ **Prosecution brief**: argue that the finding is a genuine, exploitable vulnerability. State the strongest possible case. Cite code, attacker input path, protection gaps, and reproduction evidence.
97
+
98
+ **Defense brief**: argue that the finding is a false positive or unexploitable. State the strongest possible case. Cite protections found in Step 3, reproduction failures, and any preconditions that make exploitation unrealistic.
99
+
100
+ Do not allow one brief to reference the other's reasoning. Write them independently.
101
+
102
+ ---
103
+
104
+ ## Step 6 — Severity Challenge
105
+
106
+ Apply severity calibration from `triage-and-prereqs.md`. Start at MEDIUM regardless of what the finding draft states.
107
+
108
+ - Document whether upgrade criteria for HIGH or CRITICAL are met with evidence
109
+ - Document whether any downgrade signals apply
110
+ - State `Severity-Challenge: <MEDIUM | HIGH | CRITICAL>` with a one-sentence justification
111
+
112
+ If the challenged severity is lower than `Severity-Original` in the draft, the lower severity wins in the final record.
113
+
114
+ ---
115
+
116
+ ## Step 7 — Verdict
117
+
118
+ **CONFIRMED** if both:
119
+ - The prosecution brief survives the defense (no blocking protection was found)
120
+ - AND real-environment reproduction succeeded (or reproduction was blocked with documented reason)
121
+
122
+ **DISPROVED** if either:
123
+ - The defense identifies a protection that blocks the claimed attack path
124
+ - OR all reproduction attempts failed (3 variations tried and all failed)
125
+
126
+ Write the verdict back into the finding draft:
127
+ ```
128
+ Adversarial-Verdict: CONFIRMED | DISPROVED
129
+ Adversarial-Rationale: <one sentence citing the decisive evidence>
130
+ Severity-Final: <challenged severity if different from original, else same as original>
131
+ PoC-Status: executed | theoretical | blocked
132
+ ```
133
+
134
+ Write the full adversarial review to `archon/adversarial-reviews/<slug>-review.md` using the Adversarial Review Template from `report-templates.md`.
135
+
136
+ If verdict is DISPROVED, also update the finding draft's top-level `Verdict:` field to `FALSE POSITIVE (adversarial)`.
137
+
138
+ ---
139
+
140
+ ## Rationalizations to Reject
141
+
142
+ The following are not valid grounds for issuing CONFIRMED:
143
+
144
+ - "The finding agent already verified this" — the finding agent's verification is why Stage 2 exists
145
+ - "I cannot reproduce but the code looks vulnerable" — failed reproduction with no documented blocker is a DISPROVED signal
146
+ - "Probably exploitable in some configuration" — theoretical exploitability is not confirmed exploitability
147
+ - "The severity seems right based on the bug class" — severity must be derived from evidence, not class defaults
148
+ - "The defense brief is weaker than the prosecution brief" — a plausible defense is sufficient to require reproduction before confirming
@@ -0,0 +1,306 @@
1
+ # Architecture-Aware SAST
2
+
3
+ Use this reference when Phase 3 identifies high-risk flows that built-in tooling may model incompletely.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Purpose](#purpose)
8
+ 2. [Discovery Matrix](#discovery-matrix)
9
+ 3. [SAST Layering Model](#sast-layering-model)
10
+ 4. [How DFD and CFD Drive Modeling](#how-dfd-and-cfd-drive-modeling)
11
+ 5. [Load These References Before Authoring](#load-these-references-before-authoring)
12
+ 6. [Custom CodeQL Workflow](#custom-codeql-workflow)
13
+ 7. [Custom Semgrep Workflow](#custom-semgrep-workflow)
14
+ 8. [Semgrep Resource Tuning](#semgrep-resource-tuning)
15
+ 9. [Architecture Examples](#architecture-examples)
16
+
17
+ ## Purpose
18
+
19
+ Run built-in CodeQL and built-in Semgrep coverage first. Add custom CodeQL and Semgrep coverage only when the architecture introduces blind spots:
20
+
21
+ - custom wrappers around request parsing, RPC, auth, storage, or execution
22
+ - generated interfaces, schemas, or IDLs that hide trust-boundary crossings
23
+ - unusual transports or execution models
24
+ - policy decisions separated from the dangerous sink by orchestration layers
25
+ - complex multi-component flows where attacker control or identity propagation is easy to misread
26
+
27
+ Custom rules do not replace built-in rules. They close gaps that built-ins cannot see well enough.
28
+
29
+ ## Discovery Matrix
30
+
31
+ Use this matrix to decide what must be modeled.
32
+
33
+ | Dimension | What to Inventory | Why It Matters |
34
+ |----------|-------------------|----------------|
35
+ | Ingress | HTTP handlers, CLI args, files, IPC, queues, webhooks, plugins, tool invocations | Identifies attacker-controlled sources |
36
+ | Synchronous transports | HTTP clients, RPC clients, gRPC stubs, SDK wrappers, service clients | Identifies cross-component trust handoffs |
37
+ | Asynchronous transports | queues, topics, events, schedulers, workers, retries | Identifies delayed or reordered security assumptions |
38
+ | Control-plane interfaces | admin APIs, job orchestration, deployment hooks, agent control channels | Identifies higher-privilege decision paths |
39
+ | Plugin and tool execution | extension APIs, agent tools, capability registration, command execution | Identifies confused-deputy and unsafe exposure risk |
40
+ | Storage and serialization | ORM wrappers, caches, blobs, message encoders, protocol codecs | Identifies sink classes and parser drift |
41
+ | Identity propagation | session lookup, token forwarding, headers, metadata, claims, tenant context | Identifies authn/authz blind spots |
42
+ | Dependency and supply chain edges | manifests, lockfiles, build files, images, sidecars, generated code | Identifies vulnerable libraries and hidden execution paths |
43
+
44
+ ## SAST Layering Model
45
+
46
+ Always apply SAST in this order:
47
+
48
+ 1. **Built-in CodeQL suites**
49
+ Use standard built-in suites for the languages present.
50
+ 2. **Built-in Semgrep baseline and language/framework rulesets**
51
+ Use whole-repo baseline coverage plus language and framework rulesets.
52
+ 3. **Custom CodeQL modeling**
53
+ Add data extensions and narrow QL queries where built-ins miss real flows or control invariants.
54
+ 4. **Custom Semgrep rules**
55
+ Add structural and pattern rules for unsafe registration, missing middleware, policy bypasses, and architecture-specific misuse patterns.
56
+
57
+ Document the split in the `## Static Analysis Summary` section of `archon/attack-surface/knowledge-base-report.md`.
58
+
59
+ ## How DFD and CFD Drive Modeling
60
+
61
+ Use Phase 3 outputs directly:
62
+
63
+ - **DFD slices** identify sources, summaries, sinks, trust-boundary crossings, and serialization boundaries.
64
+ - **CFD slices** identify policy gates, alternate paths, fallbacks, retries, orchestration logic, and bypass edges.
65
+
66
+ For each high-risk slice, answer:
67
+
68
+ 1. Which input is attacker-controlled?
69
+ 2. Which transformations preserve or amplify attacker influence?
70
+ 3. Which decision points gate access or privilege?
71
+ 4. Which sink causes real impact?
72
+ 5. Which part is already covered by built-in tooling?
73
+ 6. Which part needs custom modeling?
74
+
75
+ ## Load These References Before Authoring
76
+
77
+ Do not invent custom query or rule structure from memory. Open the relevant reference or template first.
78
+
79
+ **For custom CodeQL models and queries:**
80
+ - `../codeql/workflows/create-data-extensions.md`
81
+ - `../codeql/workflows/run-analysis.md`
82
+ - `../codeql/references/extension-yaml-format.md`
83
+ - `../codeql/references/diagnostic-query-templates.md`
84
+ - `../variant-analysis/resources/codeql/<language>.ql`
85
+
86
+ **For custom Semgrep rules:**
87
+ - `../variant-analysis/resources/semgrep/<language>.yaml`
88
+ - `../semgrep/references/rulesets.md`
89
+
90
+ Pick `<language>` from the repo slice you are modeling. Use the variant-analysis resources as a starting template, then narrow the pattern to the specific DFD/CFD slice.
91
+
92
+ ## Custom CodeQL Workflow
93
+
94
+ Workflow:
95
+
96
+ 1. Start from the highest-risk DFD slice.
97
+ 2. Identify missing sources, summaries, or sinks caused by wrappers, adapters, generated interfaces, or custom transport layers.
98
+ 3. Open `../codeql/workflows/create-data-extensions.md` and follow it to create the missing data extensions.
99
+ 4. Use `../codeql/references/extension-yaml-format.md` for the exact YAML columns and language-specific format rules.
100
+ 5. Use `../codeql/references/diagnostic-query-templates.md` to build source and sink enumeration queries and confirm the new models are recognized.
101
+ 6. Start the custom QL file from `../variant-analysis/resources/codeql/<language>.ql`, then narrow it to the specific invariant from the DFD/CFD slice.
102
+ 7. Add narrow custom QL queries only for architecture-specific invariants, such as:
103
+ - missing authorization gate before a privileged sink
104
+ - identity forwarded without re-verification
105
+ - unsafe fallback path after a policy failure
106
+ - parsing or schema mismatch between adjacent layers
107
+ 8. Store artifacts under `archon/codeql-queries/`. Store slice reachability queries as
108
+ `archon/codeql-queries/slice-<name>.ql` — distinct from security-finding queries; their
109
+ purpose is structural validation of Phase 3 DFD slices, not vulnerability detection.
110
+ 9. In the report, cite the DFD/CFD slice that motivated each custom model or query.
111
+
112
+ Prefer one narrow query per invariant over a broad speculative query pack.
113
+
114
+ ## Structural Extraction Workflow
115
+
116
+ Run at the start of Phase 4, before any security scan, using the freshly built database stored at
117
+ `archon/codeql-artifacts/db/`. The purpose is structural intelligence — not security findings.
118
+ The outputs feed Phase 3 KB validation, Phase 4 inline enrichment, Phase 10 deep bug hunting, and
119
+ Phase 12 variant analysis.
120
+
121
+ ### Why informational results matter
122
+
123
+ CodeQL's `note`-level and informational results represent data flow nodes that CodeQL modeled but
124
+ did not classify as exploitable under the current threat model or built-in query logic. These include
125
+ sanitizer call sites, validation function calls, encoding/decoding nodes, transformation summaries,
126
+ and intermediate propagation nodes on paths that terminate before a known sink. Retaining them gives
127
+ manual reviewers an annotated map of where CodeQL tracked data and where it stopped — a negative
128
+ result from CodeQL is as informative as a positive one.
129
+
130
+ ### Output files
131
+
132
+ All outputs go to `archon/codeql-artifacts/`:
133
+
134
+ | File | Content | Used by |
135
+ |------|---------|---------|
136
+ | `entry-points.json` | All recognized source nodes, by type and file:line | Phase 3 KB validation, Phase 5 |
137
+ | `sinks.json` | All recognized sink nodes, by kind and file:line | Phase 5, Phase 10 |
138
+ | `call-graph-slices.json` | Per-DFD-slice reachability: reachable bool, hop count, shortest paths | Phase 5, Phase 10 |
139
+ | `flow-paths-raw.sarif` | Full unfiltered SARIF including note/none severity (git-ignored) | Phase 10 on-demand |
140
+ | `flow-paths-all-severities.md` | Human-readable summary of informational/low results by rule | Phase 5, 7 |
141
+
142
+ ### Step 1: Source enumeration
143
+
144
+ For each language in the repo, run the source enumeration query (RemoteFlowSource template, adjusted
145
+ per language). Expand threat model scope if Phase 3 KB identified CLI args or env vars as
146
+ attacker-controlled.
147
+
148
+ ```bash
149
+ codeql query run \
150
+ --database=archon/codeql-artifacts/db/ \
151
+ --output=archon/codeql-artifacts/entry-points.bqrs \
152
+ -- archon/codeql-queries/list-sources.ql
153
+
154
+ codeql bqrs decode \
155
+ --format=json \
156
+ --output=archon/codeql-artifacts/entry-points.json \
157
+ archon/codeql-artifacts/entry-points.bqrs
158
+ ```
159
+
160
+ Include a `threat_model` field per record. Run additional passes with `--threat-model local` and
161
+ `--threat-model environment` as needed and merge outputs.
162
+
163
+ ### Step 2: Sink enumeration
164
+
165
+ Run the sink enumeration query for the detected language. Decode to `archon/codeql-artifacts/sinks.json`.
166
+ Group results by `kind` field.
167
+
168
+ ### Step 3: Call graph slice queries
169
+
170
+ For each high-risk DFD slice in `archon/attack-surface/knowledge-base-report.md` under
171
+ `## Phase 4 CodeQL Extraction Targets`, author a narrow QL path-problem query that tests
172
+ reachability from the identified source type to the identified sink kind. Use variant-analysis
173
+ QL templates as a starting point. Store queries at `archon/codeql-queries/slice-<name>.ql`.
174
+ Run with `--threat-model all`. Decode to JSON records in `call-graph-slices.json`:
175
+
176
+ ```json
177
+ {
178
+ "slice": "user-input-to-exec",
179
+ "reachable": true,
180
+ "path_count": 3,
181
+ "shortest_paths": [
182
+ ["src/api/handler.py:42", "src/util/shell.py:17", "src/exec/run.py:91"]
183
+ ]
184
+ }
185
+ ```
186
+
187
+ If `reachable: false`, record as a meaningful signal for Phase 5: either the DFD slice is a
188
+ false concern, or the source/sink models are incomplete and custom modeling is needed.
189
+
190
+ ### Step 4: Full raw SARIF with all severities
191
+
192
+ Run the full security-and-quality suite with `--threat-model all`, writing unfiltered output:
193
+
194
+ ```bash
195
+ codeql database analyze archon/codeql-artifacts/db/ \
196
+ --format=sarif-latest \
197
+ --output=archon/codeql-artifacts/flow-paths-raw.sarif \
198
+ --threads=0 \
199
+ --threat-model all
200
+ ```
201
+
202
+ Expect 1.5-3x the file size of the security-only SARIF. This file is git-ignored.
203
+
204
+ ### Step 5: Human-readable informational summary
205
+
206
+ Extract all `note`-level or unleveled results from the raw SARIF. Group by rule ID and write to
207
+ `archon/codeql-artifacts/flow-paths-all-severities.md` with sections per rule category. This
208
+ is the file Phase 10 reviewers read to understand where CodeQL tracked data and where it terminated.
209
+
210
+ ### Step 6: Generate Mermaid DFD and CFD diagrams
211
+
212
+ After the JSON artifacts are written, generate machine-assisted DFD and CFD Mermaid diagrams and
213
+ write them into the `## CodeQL Structural Analysis` section of `archon/attack-surface/knowledge-base-report.md`.
214
+
215
+ **DFD diagram** — derive from `entry-points.json`, `call-graph-slices.json`, and `sinks.json`:
216
+
217
+ - Nodes: all entry point file:lines as source boxes; all sink file:lines as sink boxes with their kind label
218
+ - Intermediate nodes: for each reachable slice, include the intermediate call nodes from the
219
+ shortest path array as intermediate boxes
220
+ - Solid edges: source → intermediate → sink for reachable slices
221
+ - Dashed edges with label `no path (CodeQL)`: for slices where `reachable: false`
222
+
223
+ Write the resulting `flowchart LR` Mermaid block to the `### Machine-Generated DFD Diagram`
224
+ subsection of the KB.
225
+
226
+ **CFD diagram** — derive from `flow-paths-all-severities.md` and `flow-paths-raw.sarif`:
227
+
228
+ - Extract security-relevant conditional branch points from informational CodeQL results
229
+ (guards, validators, sanitizer calls) that appear on call-graph paths
230
+ - Model each as a decision node with `passes` and `fails` edges
231
+ - Include any known fallback/alternate paths from CFD slices in the Phase 3 KB
232
+ - Write the resulting `flowchart TD` Mermaid block to the `### Machine-Generated CFD Diagram`
233
+ subsection of the KB
234
+
235
+ If a diagram would exceed ~30 nodes, limit to the highest-risk slice paths only and note the
236
+ truncation. If CodeQL extraction quality was low (few recognized sources/sinks), mark the diagram
237
+ as `[incomplete — low extraction coverage]` rather than presenting misleading auto-generated paths.
238
+
239
+ ### Step 7: Update KB — CodeQL Structural Analysis section
240
+
241
+ After all extraction steps complete, populate the `## CodeQL Structural Analysis` section of
242
+ `archon/attack-surface/knowledge-base-report.md` from the JSON artifacts:
243
+
244
+ - Fill entry point and sink tables from `entry-points.json` and `sinks.json`
245
+ - Fill the call graph reachability table from `call-graph-slices.json`
246
+ - Fill the informational flow node summary from `flow-paths-all-severities.md`
247
+ - Cross-reference with the Phase 3 KB attack surface: flag any CodeQL-discovered source
248
+ missing from `## Attack Surface Summary`
249
+ - Embed the Mermaid DFD and CFD diagrams from Step 6
250
+
251
+ ### When to skip
252
+
253
+ Skip only if the CodeQL database build fails entirely (zero extracted files). Document the skip in
254
+ `archon/attack-surface/knowledge-base-report.md`. The Phase 4 enrichment substep, Phase 10, and Phase 12 fall back to pure manual analysis.
255
+ Do not skip for small repos — call graph reachability data is most valuable where DFD construction
256
+ is complete but unvalidated.
257
+
258
+ ## Custom Semgrep Workflow
259
+
260
+ Use custom Semgrep rules for structural and local patterns that are faster to express than QL, especially when you need to detect:
261
+
262
+ - missing middleware, interceptors, or registration hooks
263
+ - unsafe handler or tool exposure
264
+ - privileged operations reachable from low-trust interfaces
265
+ - inconsistent validation or policy checks across sibling code paths
266
+ - wrappers that built-in Semgrep rules do not understand
267
+
268
+ Workflow:
269
+
270
+ 1. Start from the highest-risk CFD slice.
271
+ 2. Identify the required security gate, registration step, or wrapper contract.
272
+ 3. Start the rule from `../variant-analysis/resources/semgrep/<language>.yaml`, then replace the generic pattern with the concrete unsafe shape from the slice.
273
+ 4. Keep the rule narrow: detect the missing gate, unsafe registration, or bypass shape, not every loosely related construct nearby.
274
+ 5. Scope the rule to the relevant files, paths, or languages.
275
+ 6. Validate the rule by checking that it matches the known risky instance and does not explode into noisy unrelated results.
276
+ 7. Store artifacts under `archon/semgrep-rules/`.
277
+ 8. In the report, cite the DFD/CFD slice that motivated each custom rule.
278
+
279
+ Prefer a small set of precise rules over a large catch-all ruleset that is expensive and noisy.
280
+
281
+ ## Semgrep Resource Tuning
282
+
283
+ Semgrep Pro can be expensive on large repos. Keep coverage while avoiding host saturation:
284
+
285
+ 1. Run a whole-repo baseline pass for high-signal built-in rulesets.
286
+ 2. Separate Pro-heavy taint passes from lightweight structural passes.
287
+ 3. Batch Pro-heavy scans by high-risk subsystem or architecture slice, not all at once.
288
+ 4. Use file, path, and language scoping aggressively for targeted passes.
289
+ 5. Prefer targeted follow-up passes for custom rules instead of repeating whole-repo broad scans.
290
+ 6. Record any batching, throttling, or narrowed scope in the `## Static Analysis Summary` section of `archon/attack-surface/knowledge-base-report.md`.
291
+
292
+ The required outcome is bounded runtime without dropping mandatory built-in baseline coverage.
293
+
294
+ ## Architecture Examples
295
+
296
+ Treat these as examples, not the full scope:
297
+
298
+ - service-to-service HTTP APIs
299
+ - gRPC and generated RPC clients
300
+ - message brokers, queues, workers, and schedulers
301
+ - plugins, extensions, and tool ecosystems
302
+ - agent frameworks and MCP servers
303
+ - desktop or local IPC
304
+ - mixed control-plane and data-plane systems
305
+
306
+ The discovery matrix and DFD/CFD slices decide what to model. Do not hard-code the audit to a short list of architecture names.