Security audit

From nrdxp/predicate · View interactive version

Security audit is an AI agent skill from the GitHub repository nrdxp/predicate. 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.

How to use this skill

Skill file

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:

  1. Risk > Findings: A bug is only a finding if it poses risk to business logic or data integrity. Context determines severity.
  1. Adversarial Mindset: Analyze every input, endpoint, and public function assuming a capable adversary is attempting to subvert the system.
  1. Taint Analysis Model: For every potential vulnerability, trace:
  1. Assurance Spectrum:

Phase 0: Scope & Trust Model

Objective: Define boundaries and establish the security context before analyzing code.

0.1 Ingest System Context

  1. Read manifests (package.json, Cargo.toml, go.mod, requirements.txt)
  2. Identify tech stack and framework versions
  3. Check for known CVEs in dependencies

0.2 Define Trust Model

Establish the security context before analyzing code. Identify and document:

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:

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:

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:

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:

Apply Embedded section if:

Apply Web section if:

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):

python3 skills/security-audit/scripts/run_audit.py <path-to-audit-target>
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.