When to use
Run security auditor when you need to:- Evaluate the security posture of a specification repository
- Prepare for compliance audits (SOC2, GDPR, ISO 27001)
- Validate that security requirements cover the full threat surface
- Review security-related specs after major changes
- Assess security test coverage of specifications
- Verify traceability of security decisions (REQ→INV→ADR→BDD)
Invocation
Core principles
1. Threat-driven analysis
2. Evidence-based findings
Each finding MUST include:- OWASP ASVS v4 reference (section)
- CWE reference (ID)
- Concrete threat that exploits the gap
- Evidence from 2+ documents
3. No implementation, no assumptions
Security defect categories
SEC-CAT-01: Amenazas sin modelo (THR-)
Attack surfaces not covered by threat model. OWASP ASVS: V1 Architecture, Design, Threat Modeling Signals:- Exposed endpoints without threat analysis
- Data flows without sensitivity classification
- External integrations without trust boundary
- Actors without threat profile
SEC-CAT-02: Autenticación incompleta (AUTH-)
Gaps in authentication specification. OWASP ASVS: V2 Authentication Signals:- Endpoints without authentication requirement
- Login flows without brute force protection
- Incomplete token management (refresh, revocation, blacklist)
- MFA without recovery specification
- Session management without timeout/invalidation
SEC-CAT-03: Autorización insuficiente (AUTHZ-)
Gaps in authorization and access control specification. OWASP ASVS: V4 Access Control Signals:- Endpoints without permission in PERMISSIONS-MATRIX
- Operations without tenant isolation verification
- Privilege escalation not covered
- Incomplete RBAC (roles without operation scope)
- Row-level security not specified
SEC-CAT-04: Datos sin protección (DATA-)
PII or other sensitive data without specified protection controls. OWASP ASVS: V6 Cryptography, V8 Data Protection Signals:- PII fields without encryption marker
- Sensitive data in logs or error messages
- Data in transit without TLS specified
- Data at rest without encryption policy
- Data shared between tenants without isolation
SEC-CAT-05: Validación de entrada ausente (INPUT-)
System inputs without specified security validation. OWASP ASVS: V5 Validation, Sanitization Signals:- User inputs without validation schema
- File uploads without type/size restriction
- URL parameters without sanitization
- Queries without injection protection
- Free text fields without length limit
SEC-CAT-06: Criptografía débil o incompleta (CRYPTO-)
Weak, incomplete, or absent cryptographic specifications. OWASP ASVS: V6 Cryptography Signals:- Algorithms not specified or deprecated
- Key management without lifecycle (generation, rotation, destruction)
- IV/nonce reuse not prevented
- Key derivation without specification
- Encryption without integrity (confidentiality without authentication)
SEC-CAT-07: Respuesta a incidentes incompleta (INCIDENT-)
Gaps in detection, response, and recovery specification. OWASP ASVS: V7 Error Handling and Logging Signals:- Security events without taxonomy
- Alerts without threshold or escalation
- Incidents without runbook
- Logs without retention specified
- Incomplete audit trail
SEC-CAT-08: Compliance regulatorio incompleto (COMPLY-)
Regulatory requirements (GDPR, etc.) with specification gaps. Reference: GDPR Art. 5-34 Signals:- GDPR rights without UC or mechanism
- Consent without collection/revocation specification
- Data retention without policy or enforcement
- Cross-border data transfer without justification
- DPO/DPA without reference
SEC-CAT-09: Tests de seguridad ausentes (STEST-)
Security testing not specified in BDD/property tests. SWEBOK v4: Ch08 Software Testing Signals:- Security requirements without BDD scenario
- Authorization flows without negative test
- Input validation without property tests
- Encryption without correctness test
- GDPR flows without compliance test
SEC-CAT-10: Decisiones de seguridad sin ADR (SADR-)
Security decisions taken without formal documentation. OWASP ASVS: V1 Architecture Signals:- Cryptographic algorithms chosen without ADR
- Auth strategy without ADR
- Trust boundaries without justification
- Undocumented security trade-offs
Security Posture Scorecard
10 dimensions
| # | Dimension | Weight | Description |
|---|---|---|---|
| D1 | Authentication Completeness | 15% | All auth flows specified and protected |
| D2 | Authorization Completeness | 15% | RBAC + tenant isolation + row-level security |
| D3 | Data Protection | 15% | PII encrypted, at-rest + in-transit + key mgmt |
| D4 | Input Validation | 10% | All inputs with schema and validation |
| D5 | Cryptographic Rigor | 10% | Algorithms, key lifecycle, IV uniqueness |
| D6 | Incident Readiness | 10% | Detection, escalation, runbooks, audit trail |
| D7 | Regulatory Compliance | 10% | GDPR rights, consent, retention |
| D8 | Security Test Coverage | 5% | BDD/property tests for security requirements |
| D9 | Threat Model Coverage | 5% | Surfaces mapped with mitigations |
| D10 | Security Decision Documentation | 5% | ADRs for security decisions |
Score formula
Per dimension:Grades
| Grade | Range | Meaning |
|---|---|---|
| A | 90-100 | Solid security posture. Minor gaps. |
| B | 75-89 | Good posture. Some medium gaps to remediate. |
| C | 50-74 | Acceptable posture. Significant gaps require attention. |
| D | 25-49 | Weak posture. Multiple critical or high gaps. |
| F | 0-24 | Unacceptable posture. Requires security redesign. |
Audit process
Phase 0: Security baseline loading
- Search for
SECURITY-AUDIT-BASELINE.mdin audits directory - If baseline exists:
- Load all findings with status
accepted,wont_fix, ordeferred - Exclude these findings from report (NOT re-reported)
- Track in “Excluded by Baseline” counter
- For
deferredfindings: checkRe-evaluar endate — if past due, re-report
- Load all findings with status
- If no baseline: proceed normally (first security audit)
- Load previous security audit report to classify findings as
new,persistent, orregression
Phase 1: Security spec inventory
- Core security docs:
nfr/SECURITY.md,contracts/PERMISSIONS-MATRIX.md, security ADRs, security runbooks - Security-touching docs: All API contracts (auth per endpoint), all UCs with authorization/PII, domain model (PII fields), BDD tests with security scenarios, REQ-SEC
- Output: Complete security spec inventory with document count and coverage assessment
Phase 2: Threat surface mapping
- API surface: List all endpoints, classify (public/authenticated/admin-only), map auth requirements
- Data surface: List all PII fields, map encryption requirements, identify data flows
- Integration surface: External services (LLM APIs, OAuth, SSO), worker-to-worker, file upload/download
- Trust boundaries: Client→API, API→Storage, Worker→Worker, API→External
Phase 3: Coverage analysis
For each threat, verify that mitigation is specified:- Authentication: Every endpoint has auth? Token lifecycle? MFA for sensitive ops?
- Authorization: Every endpoint has role? Tenant isolation? Row-level security?
- Data protection: Every PII field encrypted? Key rotation? Data retention?
- Input validation: Every UC input has schema? File upload restrictions? API param validation?
Phase 4: Depth analysis
Verify internal completeness of each security spec:- SECURITY.md depth: Auth (method, hash, session, refresh, MFA, lockout), Authz (RBAC, matrix ref, tenant isolation), Crypto (algorithms, key mgmt, rotation, IV), Audit (events, retention, format), Incident (detection, response, recovery)
- PERMISSIONS-MATRIX depth: Every role has permissions, every endpoint in matrix, deny-by-default, scope qualifiers
- Security ADRs depth: Context explains threat, decision specifies control, alternatives considered, consequences include trade-offs
- Runbooks depth: Pre-requisites, step-by-step with verification, rollback, communication plan
Phase 5: Traceability verification
Verify the security traceability chain:- Forward trace: Each REQ-SEC → has INV or ADR → has UC flow → has BDD test
- Backward trace: Each security BDD → maps to UC → maps to REQ-SEC
- Gap detection: REQ-SEC without test, INV without enforcement, ADR without runbook
Phase 6: Security Posture Scorecard
- Count findings per dimension (each SEC-CAT maps to a dimension)
- Calculate score per dimension using the formula
- Calculate global score as weighted average
- Assign grade (A-F)
- Highlight weakest dimensions for priority remediation
Phase 7: Report generation
Generateaudits/SECURITY-AUDIT-REPORT-{timestamp}.md with:
- Security Posture Scorecard (10 dimensions with grades)
- Executive Summary (findings by category)
- Baseline Delta (new/persistent/regression findings)
- Threat Surface Summary (API/PII/Integrations/Boundaries coverage)
- Traceability Summary (REQ-SEC chains completeness)
- Findings by Category (10 SEC-CATs with detailed findings)
- Findings Excluded by Baseline (count and breakdown)
- Prioritization Recommendations (by severity)
Finding format
Severity classification
| Severity | Criteria | OWASP Risk |
|---|---|---|
| Crítico | Exploitable threat without specified mitigation. PII exposed. Auth bypass possible. | Critical |
| Alto | Control partially specified. Exploitable gap under conditions. | High |
| Medio | Control specified but incomplete. Missing defense-in-depth. | Medium |
| Bajo | Posture improvement without immediate threat. Missing security documentation. | Low |
Signal filters
Apply BEFORE assigning severity:- Threat requirement: Only report findings with concrete threat scenario
- Evidence from 2+ docs: Cross-reference required
- Respect security ADRs: If documented in ADR with trade-off analysis, NOT a defect
- Respect existing mitigations: Partial mitigation = Medium (not Critical)
- Implementation-blocking test: Does this gap block safe implementation?
Constraints
- Never propose implementation: Only identify gap and formulate question
- Never assume behavior: If not specified, it’s a finding
- Always include OWASP/CWE reference: Every finding with standard classification
- Always indicate concrete threat: Not “could be insecure” but “attacker can X”
- Always cross-reference documents: Minimum 2 docs per finding
- Always generate scorecard: Even if 0 findings, report all 10 dimensions
- Never duplicate with spec-auditor: Only findings with demonstrable security impact
Related skills
Spec Auditor
General quality audits (complementary)
Requirements Engineer
Derive REQ-SEC from findings
Traceability Check
Verify security traceability chains