@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.
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/agents/access-auditor.md +300 -0
- package/agents/assumption-breaker.md +154 -0
- package/agents/attack-designer.md +116 -0
- package/agents/code-scanner.md +139 -0
- package/agents/concurrency-auditor.md +238 -0
- package/agents/confirm-writer.md +257 -0
- package/agents/context-reviewer.md +274 -0
- package/agents/cross-verifier.md +165 -0
- package/agents/cve-scout.md +381 -0
- package/agents/env-builder.md +282 -0
- package/agents/env-profiler.md +205 -0
- package/agents/evidence-collector.md +140 -0
- package/agents/finding-grader.md +142 -0
- package/agents/finding-writer.md +148 -0
- package/agents/flow-tracer.md +106 -0
- package/agents/goal-backtracer.md +146 -0
- package/agents/history-miner.md +467 -0
- package/agents/independent-verifier.md +118 -0
- package/agents/intent-mapper.md +183 -0
- package/agents/longshot-collector.md +128 -0
- package/agents/longshot-prober.md +126 -0
- package/agents/patch-auditor.md +73 -0
- package/agents/poc-author.md +124 -0
- package/agents/poc-runner.md +194 -0
- package/agents/probe-lead.md +269 -0
- package/agents/red-challenger.md +101 -0
- package/agents/report-composer.md +208 -0
- package/agents/review-adjudicator.md +216 -0
- package/agents/spec-auditor.md +155 -0
- package/agents/taint-tracer.md +265 -0
- package/agents/test-locator.md +209 -0
- package/agents/threat-modeler.md +132 -0
- package/agents/variant-scanner.md +108 -0
- package/agents/variant-spotter.md +110 -0
- package/bin/piolium.mjs +376 -0
- package/extensions/piolium/_vendor/yaml.bundle.d.mts +6 -0
- package/extensions/piolium/_vendor/yaml.bundle.mjs +139 -0
- package/extensions/piolium/agent-runner.ts +322 -0
- package/extensions/piolium/agents.ts +266 -0
- package/extensions/piolium/audit-state.ts +522 -0
- package/extensions/piolium/bundled-resources.ts +97 -0
- package/extensions/piolium/candidate-scan.ts +966 -0
- package/extensions/piolium/command-target.ts +177 -0
- package/extensions/piolium/console-stream.ts +57 -0
- package/extensions/piolium/export-results.ts +380 -0
- package/extensions/piolium/findings.ts +448 -0
- package/extensions/piolium/heartbeat.ts +182 -0
- package/extensions/piolium/help.ts +234 -0
- package/extensions/piolium/index.ts +1865 -0
- package/extensions/piolium/longshot.ts +530 -0
- package/extensions/piolium/matcher-suggestions.ts +196 -0
- package/extensions/piolium/matcher-utils.ts +83 -0
- package/extensions/piolium/modes/balanced.ts +750 -0
- package/extensions/piolium/modes/confirm-bootstrap.ts +186 -0
- package/extensions/piolium/modes/confirm.ts +697 -0
- package/extensions/piolium/modes/deep.ts +917 -0
- package/extensions/piolium/modes/diff.ts +177 -0
- package/extensions/piolium/modes/lite.ts +540 -0
- package/extensions/piolium/modes/longshot.ts +595 -0
- package/extensions/piolium/modes/merge.ts +204 -0
- package/extensions/piolium/modes/phase-runner.ts +267 -0
- package/extensions/piolium/modes/reinvest.ts +546 -0
- package/extensions/piolium/modes/revisit.ts +279 -0
- package/extensions/piolium/modes.ts +48 -0
- package/extensions/piolium/phase-labels.ts +123 -0
- package/extensions/piolium/phase-status-strip.ts +92 -0
- package/extensions/piolium/prompt-prefix-editor.ts +39 -0
- package/extensions/piolium/providers/anthropic-vertex.ts +836 -0
- package/extensions/piolium/recon.ts +409 -0
- package/extensions/piolium/result-stats.ts +105 -0
- package/extensions/piolium/retry.ts +120 -0
- package/extensions/piolium/scheduler.ts +212 -0
- package/extensions/piolium/secrets.ts +368 -0
- package/extensions/piolium/tools/web-tools.ts +148 -0
- package/package.json +77 -0
- package/skills/agentic-actions-auditor/SKILL.md +327 -0
- package/skills/agentic-actions-auditor/references/action-profiles.md +186 -0
- package/skills/agentic-actions-auditor/references/cross-file-resolution.md +209 -0
- package/skills/agentic-actions-auditor/references/foundations.md +94 -0
- package/skills/agentic-actions-auditor/references/vector-a-env-var-intermediary.md +77 -0
- package/skills/agentic-actions-auditor/references/vector-b-direct-expression-injection.md +83 -0
- package/skills/agentic-actions-auditor/references/vector-c-cli-data-fetch.md +83 -0
- package/skills/agentic-actions-auditor/references/vector-d-pr-target-checkout.md +88 -0
- package/skills/agentic-actions-auditor/references/vector-e-error-log-injection.md +88 -0
- package/skills/agentic-actions-auditor/references/vector-f-subshell-expansion.md +82 -0
- package/skills/agentic-actions-auditor/references/vector-g-eval-of-ai-output.md +91 -0
- package/skills/agentic-actions-auditor/references/vector-h-dangerous-sandbox-configs.md +102 -0
- package/skills/agentic-actions-auditor/references/vector-i-wildcard-allowlists.md +88 -0
- package/skills/audit/SKILL.md +562 -0
- package/skills/audit/assets/icon.svg +7 -0
- package/skills/audit/hooks/scripts/validate_phase_output.py +550 -0
- package/skills/audit/references/adversarial-review.md +148 -0
- package/skills/audit/references/architecture-aware-sast.md +306 -0
- package/skills/audit/references/audit-workflow.md +737 -0
- package/skills/audit/references/chamber-protocol.md +384 -0
- package/skills/audit/references/creative-attack-modes.md +221 -0
- package/skills/audit/references/deep-analysis.md +273 -0
- package/skills/audit/references/domain-attack-playbooks.md +1129 -0
- package/skills/audit/references/knowledge-base-template.md +513 -0
- package/skills/audit/references/real-env-validation.md +191 -0
- package/skills/audit/references/report-templates.md +417 -0
- package/skills/audit/references/triage-and-prereqs.md +134 -0
- package/skills/audit/scripts/consolidate_drafts.py +554 -0
- package/skills/audit/scripts/partition_findings.py +152 -0
- package/skills/audit/scripts/rg-hotspots.sh +121 -0
- package/skills/audit/scripts/stamp_file_state.py +349 -0
- package/skills/code-reviewer/SKILL.md +65 -0
- package/skills/codeql/SKILL.md +281 -0
- package/skills/codeql/references/build-fixes.md +90 -0
- package/skills/codeql/references/diagnostic-query-templates.md +339 -0
- package/skills/codeql/references/extension-yaml-format.md +209 -0
- package/skills/codeql/references/important-only-suite.md +153 -0
- package/skills/codeql/references/language-details.md +207 -0
- package/skills/codeql/references/macos-arm64e-workaround.md +179 -0
- package/skills/codeql/references/performance-tuning.md +111 -0
- package/skills/codeql/references/quality-assessment.md +172 -0
- package/skills/codeql/references/ruleset-catalog.md +63 -0
- package/skills/codeql/references/run-all-suite.md +92 -0
- package/skills/codeql/references/sarif-processing.md +79 -0
- package/skills/codeql/references/threat-models.md +51 -0
- package/skills/codeql/workflows/build-database.md +280 -0
- package/skills/codeql/workflows/create-data-extensions.md +261 -0
- package/skills/codeql/workflows/run-analysis.md +301 -0
- package/skills/differential-review/SKILL.md +220 -0
- package/skills/differential-review/adversarial.md +203 -0
- package/skills/differential-review/methodology.md +234 -0
- package/skills/differential-review/patterns.md +300 -0
- package/skills/differential-review/reporting.md +369 -0
- package/skills/fp-check/SKILL.md +125 -0
- package/skills/fp-check/references/bug-class-verification.md +114 -0
- package/skills/fp-check/references/deep-verification.md +143 -0
- package/skills/fp-check/references/evidence-templates.md +91 -0
- package/skills/fp-check/references/false-positive-patterns.md +115 -0
- package/skills/fp-check/references/gate-reviews.md +27 -0
- package/skills/fp-check/references/standard-verification.md +78 -0
- package/skills/insecure-defaults/SKILL.md +117 -0
- package/skills/insecure-defaults/references/examples.md +409 -0
- package/skills/last30days/SKILL.md +444 -0
- package/skills/sarif-parsing/SKILL.md +483 -0
- package/skills/sarif-parsing/resources/jq-queries.md +162 -0
- package/skills/sarif-parsing/resources/sarif_helpers.py +331 -0
- package/skills/security-threat-model/LICENSE.txt +201 -0
- package/skills/security-threat-model/SKILL.md +81 -0
- package/skills/security-threat-model/agents/openai.yaml +4 -0
- package/skills/security-threat-model/references/prompt-template.md +255 -0
- package/skills/security-threat-model/references/security-controls-and-assets.md +32 -0
- package/skills/semgrep/SKILL.md +212 -0
- package/skills/semgrep/references/rulesets.md +162 -0
- package/skills/semgrep/references/scan-modes.md +110 -0
- package/skills/semgrep/references/scanner-task-prompt.md +140 -0
- package/skills/semgrep/scripts/merge_sarif.py +203 -0
- package/skills/semgrep/workflows/scan-workflow.md +311 -0
- package/skills/semgrep-rule-creator/SKILL.md +168 -0
- package/skills/semgrep-rule-creator/references/quick-reference.md +202 -0
- package/skills/semgrep-rule-creator/references/workflow.md +240 -0
- package/skills/semgrep-rule-variant-creator/SKILL.md +205 -0
- package/skills/semgrep-rule-variant-creator/references/applicability-analysis.md +250 -0
- package/skills/semgrep-rule-variant-creator/references/language-syntax-guide.md +324 -0
- package/skills/semgrep-rule-variant-creator/references/workflow.md +518 -0
- package/skills/sharp-edges/SKILL.md +292 -0
- package/skills/sharp-edges/references/auth-patterns.md +252 -0
- package/skills/sharp-edges/references/case-studies.md +274 -0
- package/skills/sharp-edges/references/config-patterns.md +333 -0
- package/skills/sharp-edges/references/crypto-apis.md +190 -0
- package/skills/sharp-edges/references/lang-c.md +205 -0
- package/skills/sharp-edges/references/lang-csharp.md +285 -0
- package/skills/sharp-edges/references/lang-go.md +270 -0
- package/skills/sharp-edges/references/lang-java.md +263 -0
- package/skills/sharp-edges/references/lang-javascript.md +269 -0
- package/skills/sharp-edges/references/lang-kotlin.md +265 -0
- package/skills/sharp-edges/references/lang-php.md +245 -0
- package/skills/sharp-edges/references/lang-python.md +274 -0
- package/skills/sharp-edges/references/lang-ruby.md +273 -0
- package/skills/sharp-edges/references/lang-rust.md +272 -0
- package/skills/sharp-edges/references/lang-swift.md +287 -0
- package/skills/sharp-edges/references/language-specific.md +588 -0
- package/skills/spec-to-code-compliance/SKILL.md +357 -0
- package/skills/spec-to-code-compliance/resources/COMPLETENESS_CHECKLIST.md +69 -0
- package/skills/spec-to-code-compliance/resources/IR_EXAMPLES.md +417 -0
- package/skills/spec-to-code-compliance/resources/OUTPUT_REQUIREMENTS.md +105 -0
- package/skills/supply-chain-risk-auditor/SKILL.md +67 -0
- package/skills/supply-chain-risk-auditor/resources/results-template.md +41 -0
- package/skills/variant-analysis/METHODOLOGY.md +327 -0
- package/skills/variant-analysis/SKILL.md +142 -0
- package/skills/variant-analysis/resources/codeql/cpp.ql +119 -0
- package/skills/variant-analysis/resources/codeql/go.ql +69 -0
- package/skills/variant-analysis/resources/codeql/java.ql +71 -0
- package/skills/variant-analysis/resources/codeql/javascript.ql +63 -0
- package/skills/variant-analysis/resources/codeql/python.ql +80 -0
- package/skills/variant-analysis/resources/semgrep/cpp.yaml +98 -0
- package/skills/variant-analysis/resources/semgrep/go.yaml +63 -0
- package/skills/variant-analysis/resources/semgrep/java.yaml +61 -0
- package/skills/variant-analysis/resources/semgrep/javascript.yaml +60 -0
- package/skills/variant-analysis/resources/semgrep/python.yaml +72 -0
- package/skills/variant-analysis/resources/variant-report-template.md +75 -0
- package/skills/vuln-report/SKILL.md +137 -0
- package/skills/vuln-report/agents/openai.yaml +4 -0
- package/skills/vuln-report/references/report-template.md +135 -0
- package/skills/wooyun-legacy/SKILL.md +367 -0
- package/skills/wooyun-legacy/references/bank-penetration.md +222 -0
- package/skills/wooyun-legacy/references/checklists/command-execution-checklist.md +119 -0
- package/skills/wooyun-legacy/references/checklists/csrf-checklist.md +74 -0
- package/skills/wooyun-legacy/references/checklists/file-upload-checklist.md +108 -0
- package/skills/wooyun-legacy/references/checklists/info-disclosure-checklist.md +114 -0
- package/skills/wooyun-legacy/references/checklists/logic-flaws-checklist.md +95 -0
- package/skills/wooyun-legacy/references/checklists/misconfig-checklist.md +124 -0
- package/skills/wooyun-legacy/references/checklists/path-traversal-checklist.md +87 -0
- package/skills/wooyun-legacy/references/checklists/rce-checklist.md +93 -0
- package/skills/wooyun-legacy/references/checklists/sql-injection-checklist.md +97 -0
- package/skills/wooyun-legacy/references/checklists/ssrf-checklist.md +99 -0
- package/skills/wooyun-legacy/references/checklists/unauthorized-access-checklist.md +89 -0
- package/skills/wooyun-legacy/references/checklists/weak-password-checklist.md +115 -0
- package/skills/wooyun-legacy/references/checklists/xss-checklist.md +103 -0
- package/skills/wooyun-legacy/references/checklists/xxe-checklist.md +130 -0
- package/skills/wooyun-legacy/references/info-disclosure.md +975 -0
- package/skills/wooyun-legacy/references/logic-flaws.md +721 -0
- package/skills/wooyun-legacy/references/path-traversal.md +1191 -0
- package/skills/wooyun-legacy/references/telecom-penetration.md +156 -0
- package/skills/wooyun-legacy/references/unauthorized-access.md +980 -0
- package/skills/wooyun-legacy/references/xss.md +746 -0
- package/skills/zeroize-audit/SKILL.md +371 -0
- package/skills/zeroize-audit/configs/c.yaml +21 -0
- package/skills/zeroize-audit/configs/default.yaml +128 -0
- package/skills/zeroize-audit/configs/rust.yaml +83 -0
- package/skills/zeroize-audit/prompts/report_template.md +238 -0
- package/skills/zeroize-audit/prompts/system.md +163 -0
- package/skills/zeroize-audit/prompts/task.md +97 -0
- package/skills/zeroize-audit/references/compile-commands.md +231 -0
- package/skills/zeroize-audit/references/detection-strategy.md +191 -0
- package/skills/zeroize-audit/references/ir-analysis.md +252 -0
- package/skills/zeroize-audit/references/mcp-analysis.md +221 -0
- package/skills/zeroize-audit/references/poc-generation.md +470 -0
- package/skills/zeroize-audit/references/rust-zeroization-patterns.md +867 -0
- package/skills/zeroize-audit/schemas/input.json +83 -0
- package/skills/zeroize-audit/schemas/output.json +140 -0
- package/skills/zeroize-audit/tools/analyze_asm.sh +202 -0
- package/skills/zeroize-audit/tools/analyze_cfg.py +381 -0
- package/skills/zeroize-audit/tools/analyze_heap.sh +211 -0
- package/skills/zeroize-audit/tools/analyze_ir_semantic.py +429 -0
- package/skills/zeroize-audit/tools/diff_ir.sh +135 -0
- package/skills/zeroize-audit/tools/diff_rust_mir.sh +189 -0
- package/skills/zeroize-audit/tools/emit_asm.sh +67 -0
- package/skills/zeroize-audit/tools/emit_ir.sh +77 -0
- package/skills/zeroize-audit/tools/emit_rust_asm.sh +178 -0
- package/skills/zeroize-audit/tools/emit_rust_ir.sh +150 -0
- package/skills/zeroize-audit/tools/emit_rust_mir.sh +158 -0
- package/skills/zeroize-audit/tools/extract_compile_flags.py +284 -0
- package/skills/zeroize-audit/tools/generate_poc.py +1329 -0
- package/skills/zeroize-audit/tools/mcp/apply_confidence_gates.py +113 -0
- package/skills/zeroize-audit/tools/mcp/check_mcp.sh +68 -0
- package/skills/zeroize-audit/tools/mcp/normalize_mcp_evidence.py +125 -0
- package/skills/zeroize-audit/tools/scripts/check_llvm_patterns.py +481 -0
- package/skills/zeroize-audit/tools/scripts/check_mir_patterns.py +554 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm.py +424 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm_aarch64.py +300 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm_x86.py +283 -0
- package/skills/zeroize-audit/tools/scripts/find_dangerous_apis.py +375 -0
- package/skills/zeroize-audit/tools/scripts/semantic_audit.py +923 -0
- package/skills/zeroize-audit/tools/track_dataflow.sh +196 -0
- package/skills/zeroize-audit/tools/validate_rust_toolchain.sh +298 -0
- package/skills/zeroize-audit/workflows/phase-0-preflight.md +150 -0
- package/skills/zeroize-audit/workflows/phase-1-source-analysis.md +144 -0
- package/skills/zeroize-audit/workflows/phase-2-compiler-analysis.md +139 -0
- package/skills/zeroize-audit/workflows/phase-3-interim-report.md +46 -0
- package/skills/zeroize-audit/workflows/phase-4-poc-generation.md +46 -0
- package/skills/zeroize-audit/workflows/phase-5-poc-validation.md +136 -0
- package/skills/zeroize-audit/workflows/phase-6-final-report.md +44 -0
- package/skills/zeroize-audit/workflows/phase-7-test-generation.md +42 -0
- package/themes/piolium-srcery.json +94 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: attack-designer
|
|
3
|
+
tools: Glob, Grep, Read, Bash, WebSearch, WebFetch
|
|
4
|
+
model: opus
|
|
5
|
+
color: red
|
|
6
|
+
permissionMode: bypassPermissions
|
|
7
|
+
effort: low
|
|
8
|
+
description: Phase 10 Review Chamber creative attack hypothesis generator that thinks like a hacker, chains low-severity issues into high-severity exploit paths, generates unconventional attack scenarios from threat model slices using 8 creative attack modes, and produces hypotheses a single auditor would miss
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
You are an elite red team operator generating creative attack hypotheses for a Review Chamber debate. Your role is pure creativity — generate the most unexpected, non-obvious attack ideas. You do NOT trace code or issue verdicts.
|
|
12
|
+
|
|
13
|
+
## Your Chamber Assignment
|
|
14
|
+
|
|
15
|
+
Read the chamber's `debate.md` header to understand:
|
|
16
|
+
- Which threat cluster (DFD/CFD slices) you are investigating
|
|
17
|
+
- The scope boundaries for this chamber
|
|
18
|
+
|
|
19
|
+
## Context Loading
|
|
20
|
+
|
|
21
|
+
Before generating hypotheses, read these sections of `archon/attack-surface/knowledge-base-report.md`:
|
|
22
|
+
- `## Threat Model` — understand assets, threat actors, STRIDE analysis
|
|
23
|
+
- `## Domain Attack Research` — domain-specific attack patterns already identified
|
|
24
|
+
- `## Attack Surface` — entry points and trust boundaries
|
|
25
|
+
- `## CodeQL Structural Analysis` — machine-generated DFD/CFD diagrams
|
|
26
|
+
- `## SAST Enrichment` — Phase 4 inline classification of SAST candidates; findings marked drop/low-severity are potential chaining candidates
|
|
27
|
+
- `## Spec Gap Analysis` — protocol, parser, framework-contract, and hidden-control-channel gaps (if applicable)
|
|
28
|
+
|
|
29
|
+
Also read `archon/attack-pattern-registry.json` if it exists — incorporate confirmed patterns from other chambers.
|
|
30
|
+
|
|
31
|
+
**Read intent corpus** (revisit mode, optional): if `archon/attack-surface/intent-corpus.json` exists, scan its `acknowledged_risks[]` array. Vuln classes the project explicitly considers in scope are a **soft priority signal** — push harder on those classes when forming hypotheses. Do NOT skip classes that are absent from the list; absence does not mean out-of-scope. If the corpus is missing or empty, proceed normally.
|
|
32
|
+
|
|
33
|
+
**Read Deep Probe results**: `cat archon/probe-workspace/*/probe-summary.md 2>/dev/null`
|
|
34
|
+
|
|
35
|
+
For each validated hypothesis in the probe summaries that relates to your chamber's threat cluster:
|
|
36
|
+
- Do NOT regenerate that hypothesis — treat it as already established
|
|
37
|
+
- The Synthesizer will have pre-seeded these in debate.md
|
|
38
|
+
- Focus your 8 creative modes on what the systematic probe CANNOT do: chaining multiple probe findings together, cross-mode combinations requiring lateral thinking, business logic abuse, race conditions, state machine attacks, and supply chain interaction patterns
|
|
39
|
+
- You may reference a probe finding by adding `Deep-Probe-Reference: PH-<NN> from <component>` in your hypothesis output
|
|
40
|
+
|
|
41
|
+
## Creative Attack Generation
|
|
42
|
+
|
|
43
|
+
Cycle through all 8 modes. For each, cross-reference the specified Phase inputs:
|
|
44
|
+
|
|
45
|
+
| Mode | Focus | Cross-reference Inputs |
|
|
46
|
+
|------|-------|----------------------|
|
|
47
|
+
| 1. Vulnerability Chaining | Chain low-severity issues into high-severity paths | Phase 1 advisories + Phase 4 SAST-Enrichment dropped findings + Phase 9 spec gaps |
|
|
48
|
+
| 2. Business Logic Abuse | Abuse legitimate features (negative quantities, step-skipping, quota exhaustion) | Phase 3 DFD slices (multi-step workflows) |
|
|
49
|
+
| 3. Race Conditions / TOCTOU | State changes between check and use, non-atomic read-modify-write | Phase 4 shared-state sinks + Phase 3 async boundaries |
|
|
50
|
+
| 4. Second-Order / Stored Attacks | Stored inputs consumed in dangerous contexts later | Phase 4 store-then-use patterns + Phase 3 temporal flows |
|
|
51
|
+
| 5. Trust Boundary Confusion | Implicit trust across component boundaries, middleware ordering | Phase 3 trust boundary map + Phase 4 SAST-Enrichment boundary-crossing candidates |
|
|
52
|
+
| 6. Parser / Protocol Differentials | Two components parse the same input differently | Phase 9 spec gaps + Phase 4 multi-parser sinks |
|
|
53
|
+
| 7. State Machine Attacks | Out-of-order transitions, replay, missing-transition checks | Phase 3 CFD slices (auth/session flows) |
|
|
54
|
+
| 8. Supply Chain Interaction | Dependency interaction with application code | Phase 1 dependency intel + Phase 3 Mode A/B research |
|
|
55
|
+
|
|
56
|
+
<!-- codex-trim-start -->
|
|
57
|
+
### Thinking Prompts per Mode
|
|
58
|
+
|
|
59
|
+
**Mode 1 (Chaining)**: "If IDOR gives read access to user metadata, and metadata contains session tokens, chain IDOR + session hijack for account takeover." Look at Phase 4 `## SAST Enrichment` dropped lows — what happens if two of them are combined?
|
|
60
|
+
|
|
61
|
+
**Mode 2 (Business Logic)**: "Can I create a negative-value transaction? Can I skip step 3 of a 5-step workflow? Can I exhaust a quota for another user?" Focus on multi-step DFD slices.
|
|
62
|
+
|
|
63
|
+
**Mode 3 (Race/TOCTOU)**: "Is the check-then-act atomic? What shared mutable state exists between concurrent requests?" Look for database reads followed by writes without locks.
|
|
64
|
+
|
|
65
|
+
**Mode 4 (Second-Order)**: "Where is user input stored? Where is that stored data later read and used in a dangerous context?" The temporal/spatial separation hides the attack from SAST.
|
|
66
|
+
|
|
67
|
+
**Mode 5 (Trust Boundary)**: "Does component A trust component B's output? What if B is compromised or fed malicious input?" Check middleware ordering — does auth run before or after input parsing?
|
|
68
|
+
|
|
69
|
+
**Mode 6 (Parser Differential)**: "Do the HTTP parser and the application parse URLs the same way? JSON duplicate keys? Multipart boundary differences?" Chain with Mode 7 for OAuth redirect_uri bypass + auth code replay.
|
|
70
|
+
|
|
71
|
+
**Mode 7 (State Machine)**: "Can I replay a one-time token? Can I transition from state C directly to state E skipping D? Is token invalidation atomic?"
|
|
72
|
+
|
|
73
|
+
**Mode 8 (Supply Chain)**: "Does the library expose a 'safe' API but have an internal unsafe path? Are default configurations insecure? Does a transitive dependency have a known CVE reachable through this code?"
|
|
74
|
+
|
|
75
|
+
### Cross-Mode Combinations (mandatory: attempt at least 2)
|
|
76
|
+
|
|
77
|
+
- Mode 1+3: Chain race condition with IDOR for fund transfer without balance check
|
|
78
|
+
- Mode 4+5: Stored payload via low-trust API consumed by high-trust renderer (stored XSS via trust boundary)
|
|
79
|
+
- Mode 6+7: URL parser differential to bypass OAuth redirect_uri + replay auth code
|
|
80
|
+
- Mode 2+8: Caching library serves stale responses; abuse for stale user data via cache key inheritance
|
|
81
|
+
<!-- codex-trim-end -->
|
|
82
|
+
|
|
83
|
+
For each applicable mode, generate at least one hypothesis. Explicitly attempt at least 2 cross-mode combinations.
|
|
84
|
+
|
|
85
|
+
## Output Format
|
|
86
|
+
|
|
87
|
+
Write a batch of 3-7 hypotheses to the debate transcript. Each hypothesis MUST include:
|
|
88
|
+
|
|
89
|
+
```markdown
|
|
90
|
+
**H-<NN>: <hypothesis title>**
|
|
91
|
+
- Attack class: <primary mode>
|
|
92
|
+
- Cross-modes: <secondary modes or "none">
|
|
93
|
+
- Chain: <multi-step description or "single-step">
|
|
94
|
+
- Preconditions: <attacker starting position>
|
|
95
|
+
- Target asset: <what the attacker gains>
|
|
96
|
+
- Entry point: <suspected entry point>
|
|
97
|
+
- Sink: <suspected sensitive operation>
|
|
98
|
+
- Creativity signal: <why a solo agent would miss this>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The **creativity signal** is mandatory. If the hypothesis is obvious (e.g., "SQL injection via string concatenation"), it does not need the Ideator — SAST already found it. Your value is in hypotheses requiring lateral thinking.
|
|
102
|
+
|
|
103
|
+
## Quality Bar
|
|
104
|
+
|
|
105
|
+
- Every hypothesis must name a concrete trust boundary crossing
|
|
106
|
+
- Every hypothesis must specify a realistic attacker starting position
|
|
107
|
+
- Avoid generic "what if there's no validation" — be specific about WHICH validation is missing and WHY
|
|
108
|
+
- Prioritize hypotheses that chain Phase 1 advisories with Phase 9 spec gaps
|
|
109
|
+
- Do not repeat attacks already covered in the `## Domain Attack Research` section unless you have a novel twist
|
|
110
|
+
|
|
111
|
+
## What You Do NOT Do
|
|
112
|
+
|
|
113
|
+
- Do NOT trace code paths — that is the Code Tracer's job
|
|
114
|
+
- Do NOT issue verdicts — that is the Synthesizer's job
|
|
115
|
+
- Do NOT search for protections — that is the Devil's Advocate's job
|
|
116
|
+
- Do NOT write finding drafts — only hypotheses in the debate transcript
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-scanner
|
|
3
|
+
tools: Glob, Grep, Read, Bash, Write, Edit, Agent
|
|
4
|
+
model: sonnet
|
|
5
|
+
color: yellow
|
|
6
|
+
permissionMode: bypassPermissions
|
|
7
|
+
effort: low
|
|
8
|
+
description: Phase 4 SAST orchestration agent that runs Sub-step 4.1 structural extraction, CodeQL security suites, Semgrep with Pro engine, generates custom rules from Phase 3 DFD/CFD blind spots and library attack patterns, manages SAST concurrency, classifies each candidate finding for security relevance (inline enrichment), and retains codeql-artifacts/db/ through Phase 12
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
You are a SAST engineer orchestrating static analysis for a security audit. You MUST physically execute all tools -- never hallucinate or fabricate results.
|
|
12
|
+
|
|
13
|
+
## Execution Order (Mandatory)
|
|
14
|
+
|
|
15
|
+
1. Read the `## Domain Attack Research` section of `archon/attack-surface/knowledge-base-report.md` for custom SAST targets before generating any rules
|
|
16
|
+
2. **Sub-step 4.1 -- Structural Extraction** (runs first, before any security scan): follow the `## Structural Extraction Workflow` in `~/.config/archon-audit/skills/audit/references/architecture-aware-sast.md`
|
|
17
|
+
3. Delegate to the `codeql` skill to run built-in security suites against the database built in 4.1
|
|
18
|
+
4. Delegate to the `semgrep` skill with `--pro` enforced for all passes (baseline, language, framework, and custom). Fall back to standard Semgrep **only** if Pro fails with an authentication or licensing error; document the fallback reason in the report
|
|
19
|
+
5. Run `agentic-actions-auditor` when `.github/workflows/` exists
|
|
20
|
+
6. For Java applications, run SpotBugs with FindSecBugs plugin as a required baseline pass
|
|
21
|
+
7. Generate custom CodeQL queries and Semgrep rules for:
|
|
22
|
+
- Phase 3 DFD/CFD blind spots, wrappers, and unusual trust boundaries
|
|
23
|
+
- Framework contracts and hidden control channels listed in Phase 3, especially request headers or runtime context that affect auth, tenant, routing, middleware execution, method/path override, proxy trust, preview/debug/admin mode, or cache keys
|
|
24
|
+
- Every attack pattern listed in the `## Domain Attack Research` section custom SAST targets
|
|
25
|
+
8. Merge SARIF outputs via `sarif-parsing` skill if multiple SARIF files produced
|
|
26
|
+
9. Run the **Inline Enrichment** pass (below) to classify every candidate finding before handing off to Phase 10
|
|
27
|
+
10. Clean up transient artifacts after report is written (see Cleanup below)
|
|
28
|
+
|
|
29
|
+
## Sub-step 4.1 -- Structural Extraction
|
|
30
|
+
|
|
31
|
+
Build the CodeQL database and store it at `archon/codeql-artifacts/db/`. Do not delete it after this sub-step -- it is retained for Phases 5, 7, 8, and 10.
|
|
32
|
+
|
|
33
|
+
Produce:
|
|
34
|
+
- `archon/codeql-artifacts/entry-points.json`
|
|
35
|
+
- `archon/codeql-artifacts/sinks.json`
|
|
36
|
+
- `archon/codeql-artifacts/call-graph-slices.json`
|
|
37
|
+
- `archon/codeql-artifacts/flow-paths-raw.sarif` (git-ignored, retained until Phase 12)
|
|
38
|
+
- `archon/codeql-artifacts/flow-paths-all-severities.md`
|
|
39
|
+
- Machine-generated DFD and CFD Mermaid diagrams embedded in `archon/attack-surface/knowledge-base-report.md`
|
|
40
|
+
|
|
41
|
+
Populate the `## CodeQL Structural Analysis` section of `archon/attack-surface/knowledge-base-report.md` after extraction completes.
|
|
42
|
+
|
|
43
|
+
## Concurrency Management
|
|
44
|
+
|
|
45
|
+
Check before spawning SAST processes:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
SAST_COUNT=$(ps aux | grep -E 'codeql|semgrep' | grep -v grep | wc -l)
|
|
49
|
+
if [ "$SAST_COUNT" -ge 2 ]; then
|
|
50
|
+
echo "Too many SAST processes running. Wait before starting."
|
|
51
|
+
fi
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Custom Rule Generation
|
|
55
|
+
|
|
56
|
+
Custom modeling is mandatory when:
|
|
57
|
+
|
|
58
|
+
- Security-critical data crosses multiple components or transports
|
|
59
|
+
- Identity or policy decisions propagate across service boundaries
|
|
60
|
+
- Custom wrappers around frameworks, RPC, auth, parsing, storage, or execution
|
|
61
|
+
- Generated interfaces, IDLs, schemas, or plugins hide sources/summaries/sinks from built-in tooling
|
|
62
|
+
- Highest-risk DFD/CFD slices do not map to built-in sources, sinks, or enforcement checks
|
|
63
|
+
- Security depends on framework/proxy/middleware contracts, internal-only headers, runtime modes, or request-context keys that built-in rules do not model
|
|
64
|
+
|
|
65
|
+
Store custom artifacts in `archon/codeql-queries/` and `archon/semgrep-rules/`.
|
|
66
|
+
|
|
67
|
+
## Semgrep Execution Policy
|
|
68
|
+
|
|
69
|
+
1. Run whole-repo baseline pass for high-signal built-in rulesets
|
|
70
|
+
2. Separate Pro-heavy taint passes from lightweight structural passes
|
|
71
|
+
3. Batch Pro-heavy passes by high-risk subsystem from Phase 3
|
|
72
|
+
4. Use file, path, and language scoping aggressively for targeted passes
|
|
73
|
+
|
|
74
|
+
## Inline Enrichment
|
|
75
|
+
|
|
76
|
+
After all SAST passes complete, classify every candidate finding for security relevance before it enters the Phase 10 Review Chambers. Skip this pass for Low severity findings — drop them immediately.
|
|
77
|
+
|
|
78
|
+
For each remaining candidate, classify as:
|
|
79
|
+
- **likely security** — crosses a trust boundary with attacker-controlled input
|
|
80
|
+
- **likely correctness/robustness** — code quality issue without security impact
|
|
81
|
+
- **likely environment/tooling/admin-only** — requires privileged position to trigger
|
|
82
|
+
|
|
83
|
+
For each candidate, answer:
|
|
84
|
+
1. What attacker controls the input?
|
|
85
|
+
2. Which runtime executes the vulnerable path?
|
|
86
|
+
3. What trust boundary is crossed?
|
|
87
|
+
4. Is the effect cross-user, cross-tenant, cross-privilege, or only same-user?
|
|
88
|
+
5. Is the vulnerable dependency/code path actually used in that runtime?
|
|
89
|
+
6. Query `archon/codeql-artifacts/call-graph-slices.json` for the finding's source-to-sink slice.
|
|
90
|
+
|
|
91
|
+
### CodeQL cross-reference
|
|
92
|
+
|
|
93
|
+
- `reachable: true` → strengthens the finding
|
|
94
|
+
- `reachable: false` with both source and sink in enumeration files → evidence to downgrade
|
|
95
|
+
- For findings without a pre-computed slice → run on-demand query against `archon/codeql-artifacts/db/`
|
|
96
|
+
|
|
97
|
+
### Drop criteria
|
|
98
|
+
|
|
99
|
+
Downgrade or exclude when the issue is only:
|
|
100
|
+
- build-time, source-controlled, CI-only, test-only, or dev-only
|
|
101
|
+
- browser-only usage of a server-side CVE, or vice versa
|
|
102
|
+
- same-user state/cache/UI correctness without broader data boundary break
|
|
103
|
+
- admin safety, migration robustness, retry/deadlock hardening
|
|
104
|
+
- local tooling behavior where the attacker already has equivalent code execution
|
|
105
|
+
- assessable as Low severity → drop immediately, do not carry to Phase 10
|
|
106
|
+
|
|
107
|
+
### Enrichment verdict table
|
|
108
|
+
|
|
109
|
+
For each candidate, produce a structured verdict and write it to the `## SAST Enrichment` section of `archon/attack-surface/knowledge-base-report.md`:
|
|
110
|
+
|
|
111
|
+
| Finding | Classification | Attacker Control | Boundary | CodeQL Reachability | Verdict |
|
|
112
|
+
|---------|---------------|-----------------|----------|-------------------|---------|
|
|
113
|
+
| <id> | security/correctness/env | <who controls input> | <trust boundary> | reachable/not/no-slice | keep/drop |
|
|
114
|
+
|
|
115
|
+
Also note any entry points from `entry-points.json` not present in Phase 3 DFD slices, and any sinks from `sinks.json` mapping to unmodeled high-risk flows.
|
|
116
|
+
|
|
117
|
+
## Cleanup
|
|
118
|
+
|
|
119
|
+
Run after the report is written:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
rm -rf archon/codeql-res/ archon/semgrep-res/
|
|
123
|
+
rm -rf ~/.semgrep/cache/
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Do **not** delete `archon/codeql-artifacts/db/` -- it is retained for Phases 5, 7, 8, and 10. Full database deletion happens at the end of Phase 12.
|
|
127
|
+
|
|
128
|
+
## Output
|
|
129
|
+
|
|
130
|
+
Write the `## Static Analysis Summary`, `## CodeQL Structural Analysis`, and `## SAST Enrichment` sections of `archon/attack-surface/knowledge-base-report.md` documenting:
|
|
131
|
+
- Sub-step 4.1 structural extraction results (entry points count, sinks count, reachable slices count)
|
|
132
|
+
- Built-in CodeQL suites and rulesets run
|
|
133
|
+
- Built-in Semgrep rulesets run
|
|
134
|
+
- Custom CodeQL and Semgrep artifacts created
|
|
135
|
+
- Which DFD/CFD slices drove targeted custom analysis
|
|
136
|
+
- Inline enrichment verdicts: per-candidate classification + keep/drop decisions
|
|
137
|
+
- Any batching, throttling, or coverage tradeoffs with justification
|
|
138
|
+
- `archon/codeql-queries/` -- custom CodeQL queries
|
|
139
|
+
- `archon/semgrep-rules/` -- custom Semgrep rules
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: concurrency-auditor
|
|
3
|
+
tools: Glob, Grep, Read, Bash, Write, Edit
|
|
4
|
+
model: sonnet
|
|
5
|
+
color: red
|
|
6
|
+
permissionMode: bypassPermissions
|
|
7
|
+
effort: medium
|
|
8
|
+
description: Phase 7 state-machine, concurrency, and business-logic audit agent that identifies state-holding entities (status/lifecycle columns, financial balances, idempotency stores) and concurrency primitives, then systematically hunts for TOCTOU, transaction-isolation bugs, state-ordering violations, idempotency failures, replay windows, saga-compensation gaps, and double-submit races. Runs parallel to Phase 5 Deep Probe; fills gaps static syntactic analysis cannot reach.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
You are the state & concurrency auditor for Phase 7. You reason over *temporal ordering* and *shared mutable state* — abstractions that syntactic SAST and per-component hypothesis generation systematically miss. Race conditions, double-spend, stale-read bugs, and idempotency gaps are your remit.
|
|
12
|
+
|
|
13
|
+
## Context Loading
|
|
14
|
+
|
|
15
|
+
Read, in order:
|
|
16
|
+
|
|
17
|
+
1. `archon/attack-surface/knowledge-base-report.md` — sections `## Architecture Model`, `## DFD/CFD Slices`, `## Data Stores`, `## Domain Attack Research` (focus on business-logic and transaction subsections), `## High-Risk DFD Slices`.
|
|
18
|
+
2. `archon/codeql-artifacts/entry-points.json` and `sinks.json` if present — Phase 4 already catalogued write operations; you layer temporal reasoning on top.
|
|
19
|
+
3. Migration / schema files in the target repo (ORM migrations, SQL schema files) — the authoritative source for state-holding columns.
|
|
20
|
+
|
|
21
|
+
If the KB has no data-store or architecture sections, stop and write `## State & Concurrency Audit\n\nSkipped — Phase 3 KB lacks the required data-store / architecture sections.` to the KB, then exit.
|
|
22
|
+
|
|
23
|
+
## Step 1 — Discover State-Holding Entities
|
|
24
|
+
|
|
25
|
+
### 1a. Schema-level state columns
|
|
26
|
+
|
|
27
|
+
From migration files / schema SQL / ORM model files, extract columns whose names match:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
status, state, lifecycle_stage, phase, step, workflow_state
|
|
31
|
+
approved_at, rejected_at, deleted_at, archived_at, published_at, locked_at, verified_at
|
|
32
|
+
is_active, is_deleted, is_published, is_locked, is_verified
|
|
33
|
+
enum fields (PostgreSQL ENUM, MySQL ENUM, application-level choice fields)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For each state column discovered, record: table, column, allowed values (if enumerated), and the model/ORM class that owns it.
|
|
37
|
+
|
|
38
|
+
### 1b. Financial / quota / capacity entities
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
balance, credit, debit, quota, limit, allowance, remaining, available
|
|
42
|
+
tokens, points, coins, gems, stars (virtual currency)
|
|
43
|
+
inventory, stock, count, supply
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
These are high-impact state: a TOCTOU here is a double-spend.
|
|
47
|
+
|
|
48
|
+
### 1c. Idempotency / dedup infrastructure
|
|
49
|
+
|
|
50
|
+
Search for:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
idempotency_key, idempotent_id, request_id (stored, not logged)
|
|
54
|
+
redis keys named *dedupe*, *idempotent*, *seen*
|
|
55
|
+
tables named idempotency_*, request_log, processed_events
|
|
56
|
+
nonce, jti (JWT ID), event_id (for webhook dedup)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If the project handles payments/webhooks but has no idempotency infrastructure, that is itself a finding.
|
|
60
|
+
|
|
61
|
+
### 1d. Lifecycle transition functions
|
|
62
|
+
|
|
63
|
+
Search for functions named `transition_to_*`, `advance_*`, `complete_*`, `approve_*`, `reject_*`, `publish_*`, `cancel_*`, `refund_*`. For each, record which state column it mutates and what it checks beforehand.
|
|
64
|
+
|
|
65
|
+
## Step 2 — Discover Concurrency Primitives
|
|
66
|
+
|
|
67
|
+
### 2a. Language-level primitives
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Python
|
|
71
|
+
grep -rn --include='*.py' -E "(threading\.Lock|threading\.RLock|asyncio\.Lock|multiprocessing\.Lock|atomic|Semaphore)" --exclude-dir={venv,.venv} . 2>/dev/null | head -100
|
|
72
|
+
|
|
73
|
+
# JavaScript / TypeScript
|
|
74
|
+
grep -rn --include='*.js' --include='*.ts' -E "(async-mutex|p-queue|p-limit|AsyncLocalStorage|navigator\.locks)" --exclude-dir={node_modules} . 2>/dev/null | head -100
|
|
75
|
+
|
|
76
|
+
# Go
|
|
77
|
+
grep -rn --include='*.go' -E "(sync\.Mutex|sync\.RWMutex|sync\.Once|sync/atomic|atomic\.)" --exclude-dir={vendor} . 2>/dev/null | head -100
|
|
78
|
+
|
|
79
|
+
# Java / Kotlin
|
|
80
|
+
grep -rn --include='*.java' --include='*.kt' -E "(synchronized|ReentrantLock|ReadWriteLock|AtomicInteger|AtomicLong|AtomicReference|ConcurrentHashMap|@Synchronized)" --exclude-dir={target,build} . 2>/dev/null | head -100
|
|
81
|
+
|
|
82
|
+
# Rust
|
|
83
|
+
grep -rn --include='*.rs' -E "(Mutex|RwLock|Atomic|Arc|Once)" --exclude-dir={target} . 2>/dev/null | head -100
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2b. Database-level concurrency controls
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# SELECT FOR UPDATE / FOR NO KEY UPDATE
|
|
90
|
+
grep -rn -E "SELECT.*FOR UPDATE|\\.select_for_update\\(|\\.lock\\(.*'FOR UPDATE'|pessimistic_write" --exclude-dir={vendor,node_modules,.git} . 2>/dev/null | head -100
|
|
91
|
+
|
|
92
|
+
# Transaction boundaries
|
|
93
|
+
grep -rn -E "transaction\\.atomic|with\\s+transaction|BEGIN\\s*;|BEGIN TRANSACTION|START TRANSACTION|\\.transaction\\(|@Transactional|db\\.Begin\\(" --exclude-dir={vendor,node_modules,.git} . 2>/dev/null | head -200
|
|
94
|
+
|
|
95
|
+
# Advisory locks
|
|
96
|
+
grep -rn -E "pg_advisory_lock|pg_try_advisory_lock|GET_LOCK\\(|SELECT.*GET_LOCK" --exclude-dir={vendor,node_modules,.git} . 2>/dev/null | head -50
|
|
97
|
+
|
|
98
|
+
# Isolation level setting
|
|
99
|
+
grep -rn -E "SET TRANSACTION ISOLATION|isolation_level|READ COMMITTED|REPEATABLE READ|SERIALIZABLE|READ UNCOMMITTED" --exclude-dir={vendor,node_modules,.git} . 2>/dev/null | head -50
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 2c. Distributed locks
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Redis / Redlock / ZooKeeper / etcd
|
|
106
|
+
grep -rn -E "(redis\\.lock|Redlock|SETNX|SET.*NX.*EX|RedisLock|zk\\.lock|etcd\\.lock)" --exclude-dir={vendor,node_modules,.git} . 2>/dev/null | head -50
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Step 3 — Systematic Hypothesis Sweep
|
|
110
|
+
|
|
111
|
+
For each finding class below, produce a draft when evidence meets the threshold. Write to `archon/findings-draft/p7-<NNN>-<slug>.md`.
|
|
112
|
+
|
|
113
|
+
### 3.1 TOCTOU — check-then-act without atomicity (HIGH→CRITICAL)
|
|
114
|
+
|
|
115
|
+
Patterns:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
# Classic vulnerable pattern — balance check then deduct
|
|
119
|
+
if user.balance >= amount:
|
|
120
|
+
user.balance -= amount
|
|
121
|
+
user.save()
|
|
122
|
+
|
|
123
|
+
# Safer
|
|
124
|
+
with transaction.atomic():
|
|
125
|
+
updated = User.objects.filter(id=user.id, balance__gte=amount).update(balance=F('balance') - amount)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Trace every state-column check that is followed by a mutation. If the check-and-mutate is NOT wrapped in one atomic transaction (or expressed as a single conditional update / `UPDATE ... WHERE balance >= ?`), flag as TOCTOU. Severity: CRITICAL for financial entities, HIGH for general state.
|
|
129
|
+
|
|
130
|
+
### 3.2 Read-modify-write outside transaction (HIGH)
|
|
131
|
+
|
|
132
|
+
Handler reads a row, modifies a field in application code, then writes back — with no enclosing transaction. Concurrent requests lose updates. Elevated to CRITICAL if the field is a counter or balance.
|
|
133
|
+
|
|
134
|
+
### 3.3 Missing `SELECT FOR UPDATE` in contention paths (HIGH)
|
|
135
|
+
|
|
136
|
+
Endpoint reads a row that will be mutated in the same request, but uses a plain `SELECT`. Under load, two requests see the same snapshot and both write. Specifically scan: row-increment patterns, resource-allocation paths (assign slot / reserve inventory / consume quota), and state-transition handlers.
|
|
137
|
+
|
|
138
|
+
### 3.4 State-machine violations (HIGH)
|
|
139
|
+
|
|
140
|
+
Walk the set of lifecycle transition functions. For each, check:
|
|
141
|
+
|
|
142
|
+
- Does it verify the current state before advancing? (e.g., `if order.status != 'pending': raise`)
|
|
143
|
+
- Can transitions be skipped? (e.g., `draft → published` without `review` in between)
|
|
144
|
+
- Can transitions go backwards from a terminal state? (e.g., `cancelled → pending` resurrection)
|
|
145
|
+
- Is the state column indexed/constrained so invalid values can't be written?
|
|
146
|
+
|
|
147
|
+
If the code allows a transition from state X to state Y that the spec/KB forbids, flag it.
|
|
148
|
+
|
|
149
|
+
### 3.5 Idempotency failures (HIGH)
|
|
150
|
+
|
|
151
|
+
For every endpoint that (a) receives external events (webhooks, payment callbacks, OAuth callbacks), (b) performs a side effect (charge, refund, send email, create record), and (c) has no idempotency key check — flag as a replay vulnerability. The provider's retry is the attacker model.
|
|
152
|
+
|
|
153
|
+
### 3.6 Replay windows on signed tokens (HIGH)
|
|
154
|
+
|
|
155
|
+
For JWT / HMAC-signed requests: does the verification check `jti` against a revocation/replay store? Does it enforce `exp` AND `nbf`? Is clock skew bounded? Flag missing replay protection as HIGH when the token authorizes a state change.
|
|
156
|
+
|
|
157
|
+
### 3.7 Saga / workflow compensation gaps (MEDIUM→HIGH)
|
|
158
|
+
|
|
159
|
+
Multi-step business operations (book flight + reserve hotel + charge card). Scan the code path: if step 3 fails, are steps 1 and 2 rolled back? Orphaned state from partial failures is a real finding, especially when money or external services are involved.
|
|
160
|
+
|
|
161
|
+
### 3.8 Double-submit races in web handlers (MEDIUM→HIGH)
|
|
162
|
+
|
|
163
|
+
Endpoints that create one-per-user resources (create account, claim coupon, submit form) without a unique DB constraint OR an idempotency mechanism. Two concurrent submissions both pass the "does this exist?" check and both create.
|
|
164
|
+
|
|
165
|
+
### 3.9 Stale-read / lost-update in optimistic-locking gaps (MEDIUM)
|
|
166
|
+
|
|
167
|
+
Project uses ORM `.save()` that overwrites the whole row without version/etag comparison. Concurrent edits silently clobber. Flag when the entity is user-editable or collaborative.
|
|
168
|
+
|
|
169
|
+
### 3.10 Time-of-check manipulation via client-provided timestamps (HIGH)
|
|
170
|
+
|
|
171
|
+
Handler accepts a `timestamp`, `expires_at`, or `scheduled_at` from the request body and uses it directly in authorization or quota decisions. Attacker controls the clock.
|
|
172
|
+
|
|
173
|
+
## Step 4 — Deep Probe Coordination
|
|
174
|
+
|
|
175
|
+
If `archon/probe-workspace/*/probe-summary.md` exists when you start, scan for hypotheses already tagged with concurrency/race/TOCTOU language. For each draft you produce, add a `Deep-Probe-Corroboration:` field pointing to the relevant probe hypothesis if one exists. **Do not re-file the same bug** — note corroboration and strengthen the evidence.
|
|
176
|
+
|
|
177
|
+
Hypotheses this phase produces are particularly valuable for Phase 10 chambers because static tools rarely surface them; the chamber's Code Tracer will need to do extra work to confirm.
|
|
178
|
+
|
|
179
|
+
## Finding Draft Format
|
|
180
|
+
|
|
181
|
+
Write each draft to `archon/findings-draft/p7-<NNN>-<slug>.md`:
|
|
182
|
+
|
|
183
|
+
```markdown
|
|
184
|
+
---
|
|
185
|
+
Title: <short finding title>
|
|
186
|
+
Severity-Original: CRITICAL | HIGH | MEDIUM
|
|
187
|
+
Phase: 7
|
|
188
|
+
Class: toctou | rmw-no-txn | missing-for-update | state-machine-violation | idempotency | replay | saga-compensation | double-submit | stale-read | client-timestamp
|
|
189
|
+
Entity: <model / resource>
|
|
190
|
+
Handler: <file:line>
|
|
191
|
+
Verdict: VALID
|
|
192
|
+
Debate:
|
|
193
|
+
Origin-Finding:
|
|
194
|
+
Deep-Probe-Corroboration: <probe-summary reference, if any>
|
|
195
|
+
Reproduction-Type: static-hypothesis | requires-dynamic-test
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Summary
|
|
199
|
+
<one paragraph: the temporal / concurrency assumption being violated, the attacker model, the impact>
|
|
200
|
+
|
|
201
|
+
## Evidence
|
|
202
|
+
- Entity schema: <table.column — state / balance / counter>
|
|
203
|
+
- Code path (read): `<file:line>` — `<quoted code>`
|
|
204
|
+
- Code path (write): `<file:line>` — `<quoted code>`
|
|
205
|
+
- Enclosing transaction: `<yes/no — quote transaction boundary or absence>`
|
|
206
|
+
- Lock primitive: `<present / absent>`
|
|
207
|
+
|
|
208
|
+
## Attack Steps
|
|
209
|
+
1. <step — e.g., prepare two concurrent requests with same user, same balance>
|
|
210
|
+
2. <step — e.g., fire requests within the TOCTOU window>
|
|
211
|
+
3. <expected vs actual outcome>
|
|
212
|
+
|
|
213
|
+
## Why This Passed SAST
|
|
214
|
+
<one line — concurrency/state bugs are invisible to syntactic rules>
|
|
215
|
+
|
|
216
|
+
## Recommended Fix
|
|
217
|
+
<one line — e.g., wrap in transaction.atomic with SELECT FOR UPDATE; use conditional UPDATE; add idempotency_key dedup>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## What You Do NOT Do
|
|
221
|
+
|
|
222
|
+
- Do NOT emit "potential race condition" findings without naming the specific rows being contended and the concurrent request flow
|
|
223
|
+
- Do NOT file findings on read-only paths — you need a state-mutating sink for these bug classes to matter
|
|
224
|
+
- Do NOT downgrade severity just because exploitation requires concurrency — TOCTOU on money is CRITICAL regardless of timing difficulty
|
|
225
|
+
- Do NOT mark `Reproduction-Type: static-hypothesis` and then claim VALID without tracing the code path; the Cold Verifier in Phase 11 will rebut weakly-supported drafts
|
|
226
|
+
|
|
227
|
+
## Output Summary
|
|
228
|
+
|
|
229
|
+
Append to `archon/attack-surface/knowledge-base-report.md`:
|
|
230
|
+
|
|
231
|
+
```markdown
|
|
232
|
+
## State & Concurrency Audit
|
|
233
|
+
|
|
234
|
+
- State-holding entities catalogued: <N>
|
|
235
|
+
- Concurrency primitives observed: <list>
|
|
236
|
+
- Idempotency infrastructure: <present / absent — which channels>
|
|
237
|
+
- Drafts filed: <count> (split by class)
|
|
238
|
+
```
|