원클릭으로
audit
Security and quality audit of application codebase
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Security and quality audit of application codebase
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Bridgebuilder — Autonomous PR Review
Triage a bug report through structured phases and create micro-sprint
Launch PRD discovery with codebase grounding and context ingestion
Execute sprint tasks with production-quality code and tests
Validate sprint implementation against acceptance criteria
Autonomous agent execution mode
| name | audit |
| description | Security and quality audit of application codebase |
| role | review |
| effort | high |
| allowed-tools | Read, Grep, Glob, WebFetch, WebSearch |
| disallowed-tools | ["Write","Edit","NotebookEdit"] |
| capabilities | {"schema_version":1,"read_files":true,"search_code":true,"write_files":false,"execute_commands":false,"web_access":true,"user_interaction":false,"agent_spawn":false,"task_management":false} |
| cost-profile | heavy |
| context | fork |
| parallel_threshold | 2000 |
| audit_categories | 5 |
| timeout_minutes | 60 |
| zones | {"system":{"path":".claude","permission":"none"},"state":{"paths":["grimoires/loa",".beads"],"permission":"read-write"},"app":{"paths":["src","lib","app"],"permission":"read"}} |
| inputs | [{"path":"grimoires/loa/known-failures.md","why":"Context-Intake Discipline — read first"},{"path":".claude/rules/zone-system.md","why":"System-Zone boundary the audit enforces"}] |
<input_guardrails>
Skip this section entirely when .loa.config.yaml has guardrails.input.enabled: false or env
LOA_GUARDRAILS_ENABLED=false.
Otherwise: write the user's invocation prompt/args to a temp file (Write tool), then run
.claude/scripts/guardrails-orchestrator.sh --skill auditing-security --mode ${LOA_RUN_MODE:-interactive} --file <temp-file>
| Outcome | Action |
|---|---|
JSON action: "BLOCK" | HALT; report the script's reason to the user |
JSON action: "PROCEED" or "WARN" | Continue (logging is handled by the script) |
| Script missing, non-zero exit, or unparseable output | Continue — fail-open, preserving pre-cycle-119 semantics |
Never pass prompt text as a bash argv (quote-blindness FP class) — always via --file.
</input_guardrails>
<zone_constraints>
This skill operates under Managed Scaffolding:
| Zone | Permission | Notes |
|---|---|---|
.claude/ | NONE | System zone - never suggest edits |
grimoires/loa/, .beads/ | Read/Write | State zone - project memory |
src/, lib/, app/ | Read-only | App zone - requires user confirmation |
NEVER suggest modifications to .claude/. Direct users to .claude/overrides/ or .loa.config.yaml.
When reviewing Loa-mounted projects, focus audit on app zone files (src/, lib/, app/).
Use .reviewignore patterns and zone detection from .loa-version.json to determine which files
are in scope. Files in the system zone (.claude/) and state zone (grimoires/, .beads/, .run/)
are excluded from audit by default.
To determine in-scope files, reference the shared review scope utility:
source .claude/scripts/review-scope.sh
detect_zones
load_reviewignore
# Check individual files: is_excluded "path/to/file"
Override with --no-reviewignore flag to audit everything (power user mode).
</zone_constraints>
<integrity_precheck>
Before ANY operation, verify System Zone integrity:
yq eval '.integrity_enforcement' .loa.config.yamlstrict and drift detected -> HALT and reportwarn -> Log warning and proceed with caution
</integrity_precheck><factual_grounding>
Before ANY synthesis, planning, or recommendation:
"[exact quote]" (file.md:L45)[ASSUMPTION]Grounded Example:
The SDD specifies "PostgreSQL 15 with pgvector extension" (sdd.md:L123)
Ungrounded Example:
[ASSUMPTION] The database likely needs connection pooling
</factual_grounding>
<context_discipline>
Follow .claude/protocols/tool-result-clearing.md. Thresholds: single result >2K tokens /
accumulated >5K / full file >3K / session total >15K → extract findings (≤10 files, ≤20 words
each, with file:line) to grimoires/loa/NOTES.md, then reason from the synthesis, not raw dumps.
Session start: read NOTES.md "Session Continuity". Session end / pre-compaction: update it
(decisions → Decision Log, discovered issues → Technical Debt).
</context_discipline>
<trajectory_logging>
Log each significant step to grimoires/loa/a2a/trajectory/{agent}-{date}.jsonl:
{"timestamp": "...", "agent": "...", "action": "...", "reasoning": "...", "grounding": {...}}
</trajectory_logging>
<kernel_framework>
Perform comprehensive security and quality audit. Generate reports at:
grimoires/loa/a2a/audits/YYYY-MM-DD/SECURITY-AUDIT-REPORT.mdgrimoires/loa/a2a/deployment-feedback.mdgrimoires/loa/a2a/sprint-N/auditor-sprint-feedback.mdAll audit outputs go to the State Zone (grimoires/loa/a2a/) for proper tracking.
grimoires/loa/audits/YYYY-MM-DD/Success = Comprehensive report with:
Verdicts:
<uncertainty_protocol>
<grounding_requirements> Before auditing:
<citation_requirements>
Assess codebase size to determine parallel splitting:
find . -name "*.ts" -o -name "*.js" -o -name "*.tf" -o -name "*.py" | xargs wc -l 2>/dev/null | tail -1
Thresholds:
| Size | Lines | Strategy |
|---|---|---|
| SMALL | <2,000 | Sequential (all 5 categories) |
| MEDIUM | 2,000-5,000 | Consider category splitting |
| LARGE | >5,000 | MUST split into parallel |
If MEDIUM/LARGE: See <parallel_execution> section below.
For Sprint Audit:
grimoires/loa/a2a/sprint-N/engineer-feedback.md (senior lead approval required)For Deployment Audit:
grimoires/loa/deployment/ existsdeployment-report.md for context if existsFor Codebase Audit:
Run scope analysis to understand audit surface before detailed analysis:
.claude/scripts/security-audit-scope.sh
Output Categories:
Performance Target: <30s for small repos, <2min for medium, <5min for large.
Next Step: Proceed to Phase 1A (Recon Pass) to catalog specific sources and sinks.
Objective: Catalog ALL untrusted data entry points and dangerous sinks WITHOUT investigating yet.
| Category | Patterns | Trust Level | Examples |
|---|---|---|---|
| Direct User Input | req.body, req.params, req.query | UNTRUSTED | Form data, URL params |
| Headers | req.headers, x-* | UNTRUSTED | Auth tokens, custom headers |
| Environment | process.env, os.environ | SEMI-TRUSTED | Config values |
| File Uploads | req.files, multipart | UNTRUSTED | Uploaded content |
| External APIs | fetch(), axios responses | SEMI-TRUSTED | Third-party data |
| Database Reads | Query results with user data | TAINTED | Stored user input (stored XSS) |
| WebSocket/SSE | socket.on, EventSource | UNTRUSTED | Real-time messages |
| Caches | Redis, Memcached reads | TAINTED | May contain user data |
Trust Level Decision Tree:
Is data directly from end-user? → UNTRUSTED
Was data originally from user but stored? → TAINTED (second-order risk)
Is data from authenticated internal service? → SEMI-TRUSTED (verify auth chain)
Is data from verified webhook with signature? → SEMI-TRUSTED (verify signature check)
| Category | Patterns | Risk | Sanitization Required |
|---|---|---|---|
| SQL Query | query(), execute(), raw SQL | SQL Injection | Parameterized queries |
| Command Exec | exec(), spawn(), system() | Command Injection | Allowlist, shlex |
| File I/O | readFile(), writeFile() | Path Traversal | Path normalization |
| HTML Render | innerHTML, render() | XSS | HTML encoding, CSP |
| URL Fetch | fetch(), http.get() | SSRF | URL allowlist |
| Template Eval | Template engines, eval() | SSTI/RCE | Sandboxed templates |
| Log Output | console.log(), loggers | Log Injection | Output encoding |
Create grimoires/loa/a2a/audits/YYYY-MM-DD/SECURITY_ANALYSIS_TODO.md:
# Security Analysis TODO
**Audit ID**: audit-YYYY-MM-DD-HHMMSS
**Schema Version**: 1.0
## Flagged Sources (Pass 1)
| ID | File:Line | Type | Trust | Description | Status |
|----|-----------|------|-------|-------------|--------|
| SRC-001 | src/api/users.ts:42 | direct_user_input | UNTRUSTED | User payload | PENDING |
## Flagged Sinks (Pass 1)
| ID | File:Line | Type | Risk | Status |
|----|-----------|------|------|--------|
| SINK-001 | src/db/queries.ts:89 | sql_query | SQL Injection | PENDING |
## Taint Paths (Pass 2)
| ID | Source | Sink | Hops | Sanitized | Status |
|----|--------|------|------|-----------|--------|
| PATH-001 | SRC-001 | SINK-001 | 3 | NO | CONFIRMED |
Status Values: PENDING → CONFIRMED | SAFE | PARTIAL | N/A
Triage Rules (if >100 entries per category):
overflow.jsonlObjective: For each flagged item, trace data flow and confirm/dismiss vulnerability.
For each SRC- entry:*
For each SINK- entry:*
| Repo Size | Phase 1B Budget | Max Traces |
|---|---|---|
| Small (<5K LOC) | 30 seconds | 20 |
| Medium (5-50K) | 90 seconds | 50 |
| Large (50-200K) | 180 seconds | 100 |
| XL (>200K) | 300 seconds | 150 (sampling) |
When Budget Exceeded:
PENDING with note "Deferred: time budget"| Vulnerability | Source Pattern | Sink Pattern | Sanitization |
|---|---|---|---|
| SQL Injection | req.*, db reads | query(), execute() | Parameterized queries, ORM |
| XSS | req.*, db reads | innerHTML, render() | HTML encoding, CSP |
| Command Injection | req.*, env vars | exec(), spawn() | Allowlist, shlex |
| Path Traversal | req.*, filenames | readFile(), writeFile() | Path normalization |
| SSRF | req.* (URLs) | fetch(), http.get() | URL allowlist |
Check for stored data that becomes dangerous when retrieved:
Document in TODO.md "Cross-Request Flows" section.
MANDATORY when enabled. Runs if flatline_protocol.security_audit.enabled: true in .loa.config.yaml. Skipping this phase triggers a PreToolUse:Write gate block at COMPLETED marker write time (see .claude/hooks/safety/adversarial-review-gate.sh). Emergency override only via LOA_ADVERSARIAL_REVIEW_ENFORCE=false — document in sprint notes.
Objective: Run independent security-focused cross-model review. The dissenter does NOT receive any Phase 1A/1B findings — it evaluates the code independently to prevent anchoring bias (per FR-2.5).
Steps:
git diff main...HEAD > /tmp/adversarial-audit-diff.txtfindings=$(.claude/scripts/adversarial-review.sh \
--type audit \
--sprint-id "$sprint_id" \
--diff-file /tmp/adversarial-audit-diff.txt \
--json)
Note: NO --context-file is passed — the dissenter operates independently.Output: Findings written to grimoires/loa/a2a/{sprint_id}/adversarial-audit.json
Failure mode: If unavailable (timeout, API error, budget exceeded), write grimoires/loa/a2a/{sprint_id}/adversarial-audit.json with {"findings": [], "metadata": {"status": "failed", "reason": "..."}} BEFORE proceeding — the gate hook checks for the file's presence, not its contents, so a failure record satisfies the gate while preserving the audit trail. Set DEGRADED_SECURITY_REVIEW marker if sprint completes without dissenter input (per FR-6.4). Empty findings = normal success, no DEGRADED marker.
Execute audit by category (sequential or parallel per Phase -1):
Security Audit - See resources/REFERENCE.md §Security
Architecture Audit - See resources/REFERENCE.md §Architecture
Code Quality Audit - See resources/REFERENCE.md §CodeQuality
DevOps Audit - See resources/REFERENCE.md §DevOps
Blockchain/Crypto Audit - See resources/REFERENCE.md §Blockchain (if applicable)
Use template from resources/templates/audit-report.md.
File Organization (all in State Zone):
grimoires/loa/a2a/
├── audits/ # Codebase audits
│ └── YYYY-MM-DD/
│ ├── SECURITY-AUDIT-REPORT.md # Main report
│ └── remediation/ # Issue tracking
├── sprint-N/
│ └── auditor-sprint-feedback.md # Sprint audits
└── deployment-feedback.md # Deployment audits
Creating dated directory:
mkdir -p "grimoires/loa/a2a/audits/$(date +%Y-%m-%d)/remediation"
Before writing the Verdict section, count every finding from Phase 1 by severity into a literal table:
| Severity | Count |
|---|---|
| Critical | {N} |
| High | {N} |
| Medium | {N} |
| Low | {N} |
Worked examples (severity classification per resources/RUBRICS.md):
SEC-IV score 1 — "No input validation. User input flows directly to sensitive operations." →
tally as CRITICAL (direct exploit path, no mitigating control).SEC-AZ score 2 — "Weak authorization. Easy bypass or missing on critical routes." → tally as
HIGH (exploitable but requires a specific route/condition).CQ-TC score 3 — "Moderate coverage (40-60%). Critical paths tested." → tally as MEDIUM
(quality gap, not an active vulnerability).The tally table's counts feed the Verdict rule below. ONE-WAY rule: critical + high > 0 forces
CHANGES_REQUIRED — this is the only forcing condition. Zero critical/high does NOT itself force
APPROVED; medium/low accumulation is still auditor judgment.
Sprint/Deployment Audit:
Codebase Audit:
LOA-VERDICT trailer: append as the LAST line of the audit output file (nothing after it):
<!-- LOA-VERDICT {"gate":"audit","verdict":"APPROVED|CHANGES_REQUIRED","counts":{"critical":N,"high":N,"medium":N,"low":N},"sprint_id":"sprint-N","ts":"<ISO8601>"} -->
Prose and trailer MUST agree: approved sprint/deployment audits use the exact prose
APPROVED - LET'S FUCKING GO.
MUST self-check before finishing: run
.claude/scripts/verdict-derive.sh --file <audit-output-file> --gate audit
and resolve any reported inconsistency before reporting completion to the user.
<parallel_execution>
Spawn 5 parallel Explore agents:
Focus ONLY on: Secrets, Auth, Input Validation, Data Privacy,
Supply Chain, API Security, Infrastructure Security
Files: [auth/, api/, middleware/, config/]
Return: Findings with severity, file:line, PoC, remediation
Focus ONLY on: Threat Model, SPOFs, Complexity, Scalability, Decentralization
Files: [src/, infrastructure/]
Return: Findings with severity, file:line, remediation
Focus ONLY on: Error Handling, Type Safety, Code Smells, Testing, Docs
Files: [src/, tests/]
Return: Findings with severity, file:line, remediation
Focus ONLY on: Deployment Security, Monitoring, Backup, Access Control
Files: [Dockerfile, terraform/, .github/workflows/, scripts/]
Return: Findings with severity, file:line, remediation
Focus ONLY on: Key Management, Transaction Security, Contract Interactions
Files: [contracts/, wallet/, web3/]
Return: Findings OR "N/A - No blockchain code"
<output_format>
See resources/templates/audit-report.md for full structure.
Key sections:
<rubric_scoring>
Reference: resources/RUBRICS.md
For each audit category, score each dimension 1-5 using the defined rubrics:
<structured_output>
Reference: resources/OUTPUT-SCHEMA.md
Generate machine-parseable findings alongside markdown report:
Output File: grimoires/loa/a2a/audits/YYYY-MM-DD/findings.jsonl
Generate a JSONL record with:
{
"id": "SEC-001",
"category": "security",
"criterion": "input_validation",
"severity": "HIGH",
"score": 2,
"file": "src/path/to/file.ts",
"line": 42,
"reasoning_trace": "How the issue was discovered...",
"finding": "Description of the issue",
"critique": "Specific guidance for improvement",
"remediation": "Exact fix with code example",
"confidence": "high",
"references": ["CWE-89", "OWASP-A03"]
}
Each finding MUST include a reasoning_trace explaining:
Example reasoning_trace:
"Traced user input from req.params.userId at controllers/user.ts:23 through
to database query at repositories/user.ts:42. Found string interpolation
bypassing ORM parameterization. Confirmed exploitable via payload: ' OR 1=1--"
After all findings, append a summary:
{
"type": "summary",
"timestamp": "ISO-8601",
"category_scores": {"security": 3.2, "architecture": 4.1, ...},
"overall_score": 3.8,
"risk_level": "MODERATE",
"total_findings": {"CRITICAL": 0, "HIGH": 2, "MEDIUM": 5, ...},
"verdict": "CHANGES_REQUIRED"
}
</structured_output>
<success_criteria>
<communication_style> Be direct and blunt:
Be specific with evidence:
Be uncompromising on security:
Be practical but paranoid:
<documentation_audit>
MANDATORY: For sprint audits, verify documentation coverage for all tasks.
Check task coverage:
# List all documentation-coherence reports for this sprint
ls grimoires/loa/a2a/subagent-reports/documentation-coherence-task-*.md 2>/dev/null
Verify each task has documentation report or manual verification
Check sprint-level report if available:
cat grimoires/loa/a2a/subagent-reports/documentation-coherence-sprint-*.md 2>/dev/null
See resources/REFERENCE.md §Documentation for the Security-Specific Documentation Checks and Red Flags for Documentation tables.
Add to your audit checklist:
Red Flags (immediate CRITICAL):
<beads_workflow>
When beads_rust (br) is installed, use it to record security audit results:
br sync --import-only # Import latest state from JSONL
# Add security audit comment to task/sprint epic
br comments add <task-id> "SECURITY AUDIT: [verdict] - [summary]"
# Mark security status
br label add <task-id> security # Has security concerns
br label add <task-id> security-approved # Passed audit
| Label | Meaning | When to Apply |
|---|---|---|
security | Has security-sensitive code | During review |
security-approved | Passed security audit | After "APPROVED - LET'S FUCKING GO" |
security-blocked | Critical security issue | After "CHANGES_REQUIRED" |
# Create security issue discovered during audit
.claude/scripts/beads/log-discovered-issue.sh "<sprint-epic-id>" "Security: [vulnerability description]" bug 0
br label add <new-issue-id> security
br sync --flush-only # Export SQLite → JSONL before commit
Protocol Reference: See .claude/protocols/beads-integration.md
</beads_workflow>
<retrospective_postlude>
After main skill logic completes, if .loa.config.yaml invisible_retrospective.enabled: true
(and not disabled for this skill under invisible_retrospective.skills), silently run the
learning-signal scan per .claude/skills/continuous-learning/SKILL.md and its
resources/RETROSPECTIVE.md (quality gates, sanitization, trajectory logging). Recursion guard:
never when the active skill is continuous-learning itself.
</retrospective_postlude>