---
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."
description-tr: "Bir diff, branch veya repo üzerinde bağımsız, savunma amaçlı statik güvenlik incelemesi koşar: çalışmaya özel tehdit modeli kurar, OWASP + CWE'ye bağlı, CVSS puanlı, kanıtlı ve önce/sonra düzeltmeli reviewer biçiminde bulgular üretir, bağımlılıkları çevrimdışı envanterler. Canlı hedef yok, payload yok."
argument-hint: "[#N | repo#N | PR-URL | branch | path] [--artifact=<ipa|apk|xcarchive>]  -  optional: a PR, a local branch, or a path to scope the review, plus a build of that code. If omitted (interactive), reviews the current branch diff against its base."
parameters: [{"name":"target","kind":"text"},{"name":"--artifact","kind":"path"}]
gui: form
destructive: false
confirm: none
---

# 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: it reads code, configuration and dependency manifests and reports vulnerabilities. It never runs the target, fires a payload, or reaches a live host.

## Scope resolution

Resolve what to review from `$ARGUMENTS`, same input shapes as `/multi-agent:review`:

- `#N` / `repo#N` / a PR URL (GitHub or Bitbucket Server) → that PR's diff.
- a local branch name → its diff against the base branch.
- a path → the files under it.
- omitted (interactive) → the current branch diff against its base; autopilot uses the current branch.
- `--artifact=<path>` (optional) -> a built `.ipa`, `.xcarchive`, `.app`, `.apk` or `.aab` of that code, for Step 4b.

Compute the diff once and cap it the way Phase 3 Step 1.9 does; write the capped diff to `.pipeline/security-diff.txt` when it exceeds the budget.

## Steps

### 1. Threat model

Produce `.pipeline/threat-model.md` if absent (four sections: attacker, trust boundaries, attack surface, severity calibration), or read the existing one. Contract: `$HOME/.claude/multi-agent-refs/threat-model.md`. Mirror to `state.threatModel`.

### 2. Method (the plugin skill)

Load the always-on `ai-common-toolkit:security-review` skill for the method: walk the OWASP checklist (Web/API Top 10 2021 for services and sites, Mobile Top 10 2024 for apps) against the changed surface, join each finding to a CWE, and score it. This command orchestrates; it does not re-derive the method.

### 3. Findings (the security-auditor)

Dispatch `Agent(subagent_type: "security-auditor")` on the capped diff plus the threat model. It returns one `reviewer-output.schema.json` object whose `findings[]` each carry the `security` envelope of `security-finding.schema.json`. Compute every `security.cvss.baseScore` + `band` with the toolkit `security_cvss_score` tool, so a score cannot drift from its vector. Validate the object with `$HOME/.claude/scripts/validate-reviewer.mjs`; on failure, one self-correction rework then halt.

Then prove every citation resolves: `$HOME/.claude/scripts/security-evidence-gate.mjs --findings - --root <repo>` when the pipeline scripts are installed, else `multi-agent:security_evidence_check` (`findings`, absolute `root`, optional `diff` for a diff-scoped review). Send its failures back to the auditor once; a finding whose citation still does not resolve is dropped and named in the report as "evidence did not resolve" (`security-audit.md` "Validate, persist, merge").

### 4. Dependencies (offline)

Run the toolkit `security_dep_inventory` tool on the lockfiles in scope to get a normalized `{ecosystem, name, version}` inventory. When the analyst toolkit is registered, hand that inventory to `ai-analyst-toolkit:evidence-registry` for a known-CVE lookup; a vulnerable dependency becomes an `A06:2021` finding with the advisory's CWE and CVE. This command contacts nothing itself.

### 4b. Build endpoints (optional)

With `--artifact`, run the toolkit `binary_strings_endpoints` on it: its host inventory (cleartext, ip-literal, private-network, placeholder-host) goes into the report, and a flagged URL that traces to a source location becomes a finding whose `security.evidence` cites that source line plus the build fact as a second evidence line (`binary_strings_endpoints <evidence id>: <url> in <entry> at offset 0x<hex>`, never `name:number`). A URL with no source location stays an inventory line. Toolkit absent or the tool not listed: skip silently. Rules: `$HOME/.claude/multi-agent-refs/features/build-facts.md`.

### 5. Report

Write the findings to `.pipeline/security-findings.json` (the reviewer-output object) and render a human summary: count by severity, each blocking and important finding with its OWASP id, CWE, CVSS band, evidence, and before/after fix. An empty findings list with `approved: true` is the correct result for a clean review; do not invent findings.

Optional SARIF: when the user asks for a code-scanning upload or the repo already carries a SARIF upload step, run `multi-agent:security_sarif_export` with `findings` set to the absolute path of `.pipeline/security-findings.json` and `outPath` to the absolute path of `<repo>/.pipeline/security-findings-<timestamp>.sarif`; the tool never overwrites an existing file, so pick a new name per run. Name the file in the summary. The report never depends on it.

## Relationship to the pipeline

- Inside a run, the same audit is Phase 3 Step 2.7 (`$HOME/.claude/multi-agent-refs/features/security-audit.md`), triggered by the `security_path` diff-risk signal. This command is the standalone entry point; both share the persona, the schemas and the toolkit tools.
- This is not the `store-ready` device pass under `/multi-agent:test`, and it is not a secret scanner: the pipeline's `pre-commit-check.sh` already covers secrets.
- No writes to Jira, GitHub or Confluence: routing findings to a ticket is a separate, approval-gated step.

**Autopilot**: reviews the current branch, writes the report, and never opens a PR or comments.
