| name | security-audit |
| description | Phased risk-centric security assessment framework.
Trigger when:
- Auditing code for vulnerabilities, checking SQL injection, access control, or buffer overflows.
- Prompt contains: /security-audit, security audit, taint analysis, threat model, vulnerability.
|
Security Audit Protocol
A structured, risk-centric framework for software security assessment. Designed for iterative human engagement with explicit checkpoints at each phase.
Adversarial path anchor. This lens is invoked on the Verification Dual's adversarial path (rules.md §2 Invariant 1): when no deterministic evaluator can close a security-correctness condition, context-free agents using this protocol supply the decorrelated review. See skills/refine/SKILL.md AUDIT §"Sibling Skills Consultation" for the wiring point.
Core Principle: The goal is not to maximize bug count, but to identify business risk, architectural flaws, and exploitable logic errors.
Prime Directives
Before beginning, internalize these cognitive framings:
-
Risk > Findings: A bug is only a finding if it poses risk to business logic or data integrity. Context determines severity.
-
Adversarial Mindset: Analyze every input, endpoint, and public function assuming a capable adversary is attempting to subvert the system.
-
Taint Analysis Model: For every potential vulnerability, trace:
- Source: Where does data enter? (user input, API body, URL param)
- Sink: Where is it executed? (SQL query,
eval(), HTML render, shell)
- Sanitizer: Is there validation between Source and Sink? If not, it's a vulnerability.
-
Assurance Spectrum:
- Standard code: Pattern matching, control flow analysis
- Crown jewels: Invariant checks, formal verification
Phase 0: Scope & Trust Model
Objective: Define boundaries and establish the security context before analyzing code.
0.1 Ingest System Context
- Read manifests (
package.json, Cargo.toml, go.mod, requirements.txt)
- Identify tech stack and framework versions
- Check for known CVEs in dependencies
0.2 Define Trust Model
Establish the security context before analyzing code. Identify and document:
- Untrusted sources (data entry points): API endpoints, CLI arguments, user file uploads, environment variables (if user-controlled).
- Trusted components: internal services with mTLS, signed configuration files.
- Crown jewels (what must be protected): database credentials, private keys, PII / user data, payment processing.
- Trust boundaries (where data crosses zones): external API → internal handler, user input → database query.
0.3 Map Attack Surface
Checkpoint: Present scope and trust model. Await user approval before proceeding.
Phase 1: Automated Baseline
Objective: Establish security baseline through breadth-first automated analysis.
1.1 Secret Detection
Search for high-entropy strings and credential patterns:
AWS_ACCESS_KEY, AZURE_, GCP_
Bearer , Authorization:
- Private key headers (
-----BEGIN)
- Database connection strings
- API keys matching known formats
1.2 Dangerous Sink Detection
Search for risky function calls:
| Language | Dangerous Patterns |
|---|
| Python | eval(), exec(), subprocess.call(shell=True), os.system() |
| JavaScript | eval(), Function(), innerHTML, dangerouslySetInnerHTML |
| Go | os/exec without validation, template.HTML() |
| Rust | unsafe, .unwrap() in library paths, raw pointer manipulation |
| C/C++ | strcpy, sprintf, gets, system(), raw malloc |
| SQL | String concatenation in queries, missing parameterization |
1.3 Configuration Audit
1.4 Dependency Vulnerability Check
Checkpoint: Present baseline findings. Await acknowledgment before deep review.
Phase 2: Manual White-Box Review
Objective: Deep analysis of logic, access control, and architectural patterns that tools miss.
Coherence Strategy: Analyze ONE component at a time. Present findings. Await acknowledgment before proceeding.
2.1 Authentication & Session Management
2.2 Authorization & Access Control
IDOR Trace Pattern:
API Endpoint → Extract resource_id from request
→ Verify current_user owns/can_access resource_id
→ If not verified: VULNERABILITY
2.3 Input Validation & Injection
2.4 Business Logic Errors
Apply state machine analysis:
- Can user do X before Y? (sequence violations)
- Can user trigger action twice? (replay attacks)
- Can user manipulate timing? (TOCTOU)
- Are negative values handled? (refund more than paid)
2.5 Concurrency & Race Conditions
2.6 Cryptography
2.7 Error Handling & Information Disclosure
Component Audit Template
For each component, produce:
## Audit: [Component Name]
### Attack Surface
- Entry points: [list]
- Data handled: [list]
### Findings
| Category | Rating | Notes |
|:---------|:-------|:------|
| AuthN/AuthZ | PASS/WARN/FAIL | — |
| Input Validation | PASS/WARN/FAIL | — |
| Crypto | N/A/PASS/WARN/FAIL | — |
| Error Handling | PASS/WARN/FAIL | — |
### Vulnerabilities
1. **[SEVERITY]** Brief description — Location
### Questions for User
1. [Clarifying question if needed]
Checkpoint: Present findings for this component. Await acknowledgment before next component.
Phase 3: Formal Verification (Conditional)
Trigger: Apply ONLY to crown jewels—smart contracts, cryptographic primitives, safety-critical logic.
3.1 Invariant Definition
Define mathematical properties that must always hold:
total_supply == sum(all_balances)
user_balance >= 0
session.expires_at > now() implies session.valid
3.2 Property Verification
3.3 Traceability
Checkpoint: Present formal verification scope and findings.
Phase 4: Report Generation
Objective: Produce actionable, prioritized findings.
Severity Classification
| Level | Definition | Example |
|---|
| Critical | Immediate exploitation possible; complete compromise | RCE, auth bypass, SQLi with admin access |
| High | Significant impact; exploitation requires minimal effort | Stored XSS, privilege escalation, IDOR on sensitive data |
| Medium | Moderate impact or requires specific conditions | CSRF, information disclosure, weak crypto |
| Low | Minor impact; defense in depth issue | Missing headers, verbose errors, weak rate limiting |
Report Structure
# Security Audit Report: [Project Name]
## Executive Summary
- **Overall Risk:** [Critical / High / Medium / Low]
- **Summary:** [3-4 sentences, non-technical]
- **Priority Action:** [Single most important fix]
## Threat Model
- **Attack Surface:** [Entry points]
- **Crown Jewels:** [What's at risk]
- **Trust Boundaries:** [Where validation is critical]
## Findings
### [ID-001] [Vulnerability Name]
- **Severity:** Critical/High/Medium/Low
- **Location:** `file:line`
- **Description:** [Technical explanation]
- **Impact:** [Business consequence]
- **Proof of Concept:**
> [Steps or payload to trigger]
- **Remediation:**
- _Root Cause:_ [Why this happened]
- _Fix:_ [Specific code change]
### [ID-002] ... (repeat)
## False Positives
- [Pattern investigated, determined safe, explanation]
## Recommendations (Systemic)
1. [Process or architectural improvement]
Master Checklist
Cross-reference all findings against these controls:
Architecture & Design
Authentication
Authorization
Input Handling
Cryptography
Infrastructure
Domain-Specific Extensions
During Phase 0 (Scope), identify the tech stack and leverage the appropriate section of the unified security-audit skill (skills/security-audit/SKILL.md). These provide specialized checklists and vulnerability patterns.
Relevant Audit Sections
Apply Web3 section if:
- Auditing Solidity, Vyper, or other smart contract languages
- Target is a blockchain application, DeFi protocol, or NFT system
- Code handles tokens, balances, or on-chain state
- Upgrade patterns (proxy contracts) are in use
Apply Embedded section if:
- Auditing C/C++ firmware or RTOS applications
- Target has real-time constraints or safety requirements
- DO-178C, ISO 26262, or IEC 62443 compliance is required
- Code runs on microcontrollers, automotive ECUs, or medical devices
Apply Web section if:
- Auditing a web application or REST/GraphQL API
- Using Python, Node.js, Go, Ruby, or similar web frameworks
- Target handles user authentication, sessions, or file uploads
- Code is publicly exposed on the internet
Note: Multiple sections may apply. A Web3 project with a backend API might require auditing against both Web3 and Web sections of the security-audit skill.
Final Directive
This protocol enforces iterative human engagement. Never skip checkpoints. If findings accumulate beyond trackable scope, pause and summarize before continuing.
The goal is not a comprehensive bug list, but accurate risk assessment that enables informed remediation decisions.
Platform Checklists
This section provides domain-specific security checklists and threat models to guide code audits across different platforms, referencing the target stack identified in Phase 0.
1. Web & API Applications
Injection Attacks
Authentication & Authorization
Network & API Concerns
2. Embedded & Safety-Critical Systems
Memory Safety (C/C++)
Real-Time & Physical Controls
3. Web3 & Smart Contracts
Vulnerability Classes
Utility Script Usage
You can run automated checks using the script located in scripts/run_audit.py. It automatically detects project files in the target path and runs the corresponding security audit tools (providing setup commands for missing tools):
- Python: Runs static analysis with
bandit.
- Solidity: Scans contracts with
slither.
- Rust: Invokes
cargo clippy (denying warnings) and cargo audit.
- Go: Scans for known vulnerabilities using
govulncheck.
- JavaScript/TypeScript: Audits package dependencies using
npm audit, yarn audit, or pnpm audit.
python3 skills/security-audit/scripts/run_audit.py <path-to-audit-target>