/ccmaf:securityfrom ccmaf
Security sweep — SAST, secret scanning, dependency scanning and license/provenance checks (CCMAF v2)
Ships in ccmaf. Installing the plugin adds it to Claude Code.
This command runs only in a CCMAF v2 project. Check
.claude/.framework-version before doing anything else:
.claude/.framework-version — this
isn't a CCMAF-scaffolded project") and stop.FRAMEWORK_LINE=v2 → say "this is a v1-line CCMAF
project — use the bundled /security or migrate" and stop.FRAMEWORK_LINE=v2 → continue.Security sweep across the project: SAST, secret scanning, dependency
scanning, and license/provenance check. Stack-agnostic — dispatches by
manifest presence (same approach as init.sh and auto-format.sh). Each
check is opt-in by tool availability; missing tooling produces an
informational note rather than a hard failure.
This command exists because AI-generated code consistently surfaces in research with concrete security failure modes: ~40% of high-risk scenarios vulnerable in one Copilot study, package-hallucination rates ≥5.2% commercial / ≥21.7% open-source, and SQL/path/shell injection patterns repeatedly observed in real AI-authored commits. Layered automated checks catch a meaningful fraction before review.
This is complementary to the reviewer agent's per-PR security
checklist — /security is the broader sweep across the whole project,
not just the diff. Run it before major merges, on a periodic cadence, or
when /healthcheck nudges.
Below is a runbook. Follow in order. Each step is independent — if one tool isn't installed, skip and note it; don't halt.
Output discipline. For any finding about a safety or security control, record the weakness class and the defensive fix only — never a working bypass, a runnable payload, or a destructive-command list. Naming the class and the fix is a complete finding — keep class-level precision, not vague. (Tool output — gitleaks/SAST/SCA — is captured as the tool emits it.)
Same auto-detection logic as /healthcheck Part 0. Specifically:
CLAUDE.md Commands section, then common
layouts (01_Project/src/, 02_src/*/, src/, app/, lib/).package.json → Node/TS ecosystem (npm/pnpm/yarn)pyproject.toml or requirements.txt → PythonCargo.toml → Rustgo.mod → Go*.csproj or *.sln → .NET.claude/security-findings.md
with the same rotation pattern /healthcheck uses (move any prior
findings to .claude/security-findings/<ISO>.md first, then start
fresh). Rationale: same anchoring failure mode (BUG-001).Tell the user what was detected before running expensive steps. Ask for confirmation via AskUserQuestion if any tool is about to make network calls (advisory lookups, SCA against public databases).
Goal: detect credentials, API keys, tokens, private keys in the working tree. Prefer in priority order; first one available wins.
gitleaks dir --no-banner --redact . scans
the working tree on disk, uncommitted files included (v8.19+; on older
builds gitleaks detect --no-git --no-banner --redact). Also run
gitleaks git --no-banner --redact (older: gitleaks detect --no-banner --redact) — that mode scans commit HISTORY only, which catches a secret
deleted from the tree but still in a past commit, but it never sees
uncommitted changes, so it is an addition to the dir scan, not a
substitute for it.trufflehog filesystem --no-update .grep -rIn --include='*.py' --include='*.ts' --include='*.js' \
--include='*.tsx' --include='*.jsx' --include='*.go' \
--include='*.rs' --include='*.cs' --include='*.json' \
--include='*.yml' --include='*.yaml' --include='*.toml' \
--include='.env*' \
-E '(AKIA[0-9A-Z]{16}|sk-[A-Za-z0-9]{20,}|ghp_[A-Za-z0-9]{36}|xox[bpars]-[A-Za-z0-9-]+|-----BEGIN (RSA |DSA |EC |OPENSSH |)PRIVATE KEY-----|password[[:space:]]*=[[:space:]]*["'\''][^"'\'']+["'\''])' \
. 2>/dev/null
Findings go to security-findings.md as SECRET — — file:line — .
Severity: any real key found → CRITICAL. Pattern-match in a test file or fixture → WARNING (likely intentional). False positives on dummy-data strings → SUGGESTION.
Pick the tool that matches the stack. Each is opt-in by tool availability.
| Stack | Preferred | Fallback |
|---|---|---|
| Python | bandit -r <src> | ruff check --select=S <src> (S is bandit-like ruleset) |
| Node/TS | semgrep --config=p/javascript --config=p/typescript . — ONLY if command -v semgrep (install: pip install semgrep or brew install semgrep). Do NOT npx semgrep: the npm package named semgrep is a v0.0.1 name-squat, not the tool — npx would fetch and run it (the exact slopsquat this command warns about). Missing → use the fallback. | npm audit --audit-level=moderate (covers SCA too) |
| Go | gosec ./... | go vet ./... |
| Rust | cargo clippy -- -W clippy::all -W clippy::pedantic (cherry-pick security lints) | cargo audit (covers SCA) |
| .NET | dotnet list package --vulnerable --include-transitive + Roslyn analyzers | — |
| Any | semgrep --config=auto . (cross-language) | — |
Capture findings classified as security/CWE; ignore style-only lints
(auto-lint hook covers those). Severity follows the tool's classification
(HIGH/MEDIUM/LOW); map to CRITICAL/WARNING/SUGGESTION in
security-findings.md.
AI-specific patterns to grep for explicitly (even if SAST passed), since these are the most-reported AI failure modes in published studies:
# SQL string interpolation (Microsoft data-formulator case). One call prefix, then the
# INTERPOLATING first-argument forms only: JS template ${...}, Python f-string, a literal
# followed by the % operator, + concatenation, or .format(). A parameterised call —
# execute("... %s", (x,)) / query('... ?', [x]) — has a comma after the literal and is
# NOT flagged.
Q="[\"'\`]"
grep -rIn -E "(execute|query|exec|raw)[[:space:]]*\([[:space:]]*(\`[^\`]*\\\$\{|[fF]$Q[^\"']*\{|$Q[^\"'\`]*$Q[[:space:]]*(%|\+|\.format\())" <src> 2>/dev/null
# Bare exception swallowing (Claude ArchiveBox case)
grep -rIn -E '^\s*(except:|except Exception:|catch\s*\([^)]*\)\s*\{\s*\}|catch\s*\(_\))' <src> 2>/dev/null
# User input → shell
grep -rIn -E '(os\.system|subprocess\.(Popen|run|call)\([^)]*shell=True|child_process\.exec)' <src> 2>/dev/null
# eval / exec / new Function on dynamic input
grep -rIn -E '\b(eval|exec|new Function)\b' <src> 2>/dev/null
# Path traversal — file path constructed from user input without basename/realpath check
grep -rIn -E '(open|readFile|fs\.read|os\.open)[[:space:]]*\([^)]*\b(req\.|request\.|params\.|input|argv)' <src> 2>/dev/null
Treat any match as CRITICAL unless you can rule it out by reading the surrounding context.
Goal: known-vulnerable or known-malicious dependencies, plus existence verification of every newly-added package (slopsquatting defense).
By stack:
npm audit --omit=dev --audit-level=moderate — captures
HIGH/CRITICAL advisories. If better-npm-audit is already installed
(command -v better-npm-audit), also run better-npm-audit audit for
SARIF output — do NOT npx-fetch it on demand (unpinned npx <tool>
auto-install is the slopsquat surface Part 4a flags as CRITICAL).pip-audit (if installed) or safety scan against
requirements.txt / pyproject.toml. If neither installed, query
PyPI for each new dep's existence (the verify-deps.sh hook covers
this on edit; here, run it across the full manifest):
for pkg in $(grep -oE '^[a-zA-Z0-9_.-]+' requirements.txt 2>/dev/null); do
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "https://pypi.org/pypi/$pkg/json")
[ "$code" = "404" ] && echo "MISSING: $pkg"
done
cargo audit (RustSec advisory database).govulncheck ./... if installed.dotnet list package --vulnerable --include-transitive.Cross-stack: any new dependency added in the last git log window
that the verify-deps hook flagged in .claude/.dep-verification-issues.md
gets re-checked here (in case the file was deleted without resolving the
issues).
Findings go to security-findings.md as DEPENDENCY — —
package@version — <advisory ID or "missing">.
This is the harness's own attack surface — distinct from project code (Parts 1-3). Run the deterministic auditor first, then the manual spot-checks it doesn't cover.
4a — Config-surface auditor (run always):
bash ${CLAUDE_PLUGIN_ROOT}/audit/config-security.sh
This scans five surfaces and reports CRITICAL/WARNING/INFO findings
(exit 2 on any CRITICAL, so it doubles as a CI build gate —
config-security.sh --format json for pipelines):
.env, ~/.ssh, ~/.aws, *secret*, *credential*).curl|bash / remote-code execution, eval, and unquoted
interpolation of model-controlled tool_input (shell-injection)..mcp.json / settings mcpServers) — unpinned
npx -y/uvx auto-install and shell-piped server commands.Fold its findings into security-findings.md (same SEV mapping).
WARNINGs need human triage — some are intentional (e.g. a test-command
rewriting hook that embeds $cmd by design).
4b — Manual spot-checks (auditor doesn't cover these):
.gitignore covers .env, .env.*, settings.local.json,
worktrees/, .claude/review-findings/, .claude/security-findings/,
any project-specific secret files.git commit --no-verify leaves no trace in a
commit, so it cannot be detected from history after the fact — check the
configuration that would make bypass silent instead:
git config --show-origin --get core.hooksPath is unset or points at the
project's expected hooks dir (not an empty/disabled one), and, only if the
project requires signed commits, git log --format='%h %G? %s' -20 shows
no N (unsigned) entries.These overlap with doctor.sh Check 1 / /healthcheck Part 1.3 (which
check config integrity — do referenced files exist); Part 4 checks
config security — is the configuration itself a risk.
Goal: licence-incompatible code, attribution gaps, public-code matches that may indicate verbatim copy. Skip if the project is fully internal and not redistributed.
license-checker --production --summary — only if command -v license-checker (install npm i -g license-checker); skip rather than
npx-fetching it on demand (unpinned auto-install — see Part 4a).pip-licenses --format=markdown if installedcargo about generate if installedgo-licenses report ./... if installedSame as /healthcheck Part 6-7:
claude-progress.txt.What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub drushegh/ccmaf --plugin ccmaf16 commands in this plugin
/analyseContext checkArchitect analysis of requirements and existing code into a design and task breakdown (CCMAF v2)/board-healContext checkReconcile the TASKS.md board with reality — advance stranded tasks, backfill verify seeds, fix IDs (CCMAF v2)/bugContext checkLog an ad-hoc bug into the TASKS.md Bug-Fix Lane in the shared on-disk bug shape (CCMAF v2)/build/ccmaf:build — the thin build loopTHIN build loop — dispatch against plan specs with budgets, receipts, integration gate, staged review (CCMAF v2)/healthcheckContext checkDeep periodic audit across framework integrity, code quality, contracts, state files and tests (CCMAF v2)/housekeepingContext checkFramework maintenance — rolling summary, state archiving and distillation, feedback reconciliation (CCMAF v2)Other plugins' commands for the same job