---
name: multi-agent-security-review
description: "Run a standalone defensive, static security review of a diff, a branch or a repo: build a run-scoped threat model, emit reviewer-shaped findings joined to OWASP + CWE with CVSS scoring, evidence and before/after fixes, and inventory dependencies offline. No live target, no payloads. Use when reviewing code for security outside a full pipeline run, auditing a dependency set, or preparing a branch for a security sign-off."
user-invocable: true
argument-hint: "[#N | repo#N | PR-URL | branch | path] [--artifact=<ipa|apk|xcarchive>]  -  a PR, a local branch, or a path to scope the review, plus a build of that code. If omitted: the current branch diff against its base."
metadata:
  language: en
---

# multi-agent security-review  -  standalone defensive static review

**Input**: `$ARGUMENTS`

The same security audit Phase 3 runs at Step 2.7, invoked on its own. Defensive and static: reads code, config and dependency manifests; never runs the target, fires a payload, or reaches a live host.

## Scope

Resolve from `$ARGUMENTS`, same shapes as `/multi-agent:review`: `#N` / `repo#N` / PR URL -> that PR's diff; a branch -> its diff against base; a path -> files under it; omitted -> the current branch diff. Cap the diff as Phase 3 Step 1.9 does. `--artifact=<path>` (optional) names a built `.ipa` / `.xcarchive` / `.app` / `.apk` / `.aab` of that code.

## Steps

1. **Threat model** - produce `.pipeline/threat-model.md` (four sections) if absent, else read it; mirror to `state.threatModel`. Contract: `threat-model.md`.
2. **Method** - load `ai-common-toolkit:security-review` for the OWASP walk (Web/API Top 10 2021, Mobile Top 10 2024) + CWE join. This command orchestrates, it does not re-derive the method.
3. **Findings** - dispatch the `security-auditor`; it returns a `reviewer-output.schema.json` object whose `findings[]` carry the `security` envelope (`security-finding.schema.json`). Score every vector with the toolkit `multi-agent:security_cvss_score`; validate with `validate-reviewer.mjs` (one rework then halt). Then prove every citation resolves with `security-evidence-gate.mjs`, or `multi-agent:security_evidence_check` (`findings`, absolute `root`, optional `diff`) where the pipeline scripts are absent; a citation that still fails after one rework drops its finding, named in the report.
4. **Dependencies** - run `multi-agent:security_dep_inventory` on the lockfiles; hand the inventory to `ai-analyst-toolkit:evidence-registry` for known CVEs when it is registered. A vulnerable dependency is an `A06:2021` finding with the advisory CWE + CVE. This command contacts nothing itself.
4b. **Build endpoints (optional)** - with `--artifact`, `multi-agent:binary_strings_endpoints` gives the host inventory for the report; a flagged URL that traces to a source line becomes a finding citing that line plus the build fact as a second evidence line in the form the ref gives (tool, evidence id, URL, entry, hex offset; never `name:number`). Toolkit absent or the tool not listed: skip silently. Rules: `features/build-facts.md`.
5. **Report** - write `.pipeline/security-findings.json` and a human summary (count by severity; each blocking/important finding with OWASP id, CWE, CVSS band, evidence, before/after fix). An empty list with `approved: true` is a clean review.
6. **SARIF (optional)** - on request, or when the repo uploads SARIF already, `multi-agent:security_sarif_export` with `findings` = the absolute path of `.pipeline/security-findings.json` and `outPath` = the absolute path of `<repo>/.pipeline/security-findings-<timestamp>.sarif` (the tool never overwrites, so pick a new name per run); the report never depends on it.

## Boundaries

Inside a run the same audit is Phase 3 Step 2.7 (`features/security-audit.md`), triggered by the `security_path` signal; this is the standalone entry point. Not the `store-ready` device pass, not a secret scanner (`pre-commit-check.sh` covers secrets). No writes to Jira / GitHub / Confluence. Autopilot reviews the current branch, writes the report, opens no PR.
