Add security audit

From brabos-ai/code-addiction · View interactive version

Add security audit is an AI agent skill from the GitHub repository brabos-ai/code-addiction. Security audit: OWASP Top 10, multi-tenancy, injection, auth, XSS, dependencies.

How to use this skill

Skill file

Security Audit

Use for: Validate security, audit codebase, identify vulnerabilities

Do not use for: Writing security fixes, dependency upgrades, incident response, general code review

Reference: Project conventions: follow {{addpath:wiki/conventions.md}} → ## Stack Conventions (+ {{addpath:wiki/domains/<area>.md}}); a one-line critical rule may live in AGENTS.md. If absent, apply the agnostic defaults and follow the nearest existing code; never impose tenancy, DI registration or barrels unless the project uses them.


OWASP Checklist

A01 — Broken Access Control (CRITICAL)

When row Tenancy = yes (the key is the recorded one, e.g. account_id):

Always:

Searches to run (examples):


A02 — Cryptographic Failures

Searches:


A03 — Injection (CRITICAL)

SQL/NoSQL:

Command injection:

Searches:


A04 — Insecure Design

Search: grep '@Get|@Post' → check @UseGuards.


A05 — Misconfiguration

Secrets/env vars: see A02.

Searches:


A06 — Vulnerable Components

Command: npm audit --json | grep -E 'critical|high'.


A07 — Auth Failures


A08 — Integrity Failures


A09 — Logging Failures

Sensitive data in logs: see A02.


A10 — SSRF


Extra — XSS

Search: grep 'dangerouslySetInnerHTML' → check sanitization.


Extra — Mass Assignment

Search: grep '...body|...dto' → spread vulnerability.


Scoring

Formula: score = 10 - (weighted_sum / 5)

| Severity | Weight | Score Range | Status |

|----------|--------|-------------|--------|

| critical | 3 | 8-10 | ✅ Secure |

| high | 2 | 6-7 | ⚠️ Attention |

| medium | 1 | 4-5 | 🟠 Risk |

| low | 0.5 | 0-3 | 🔴 Vulnerable |


Process

  1. Setup: Read security.md, the project conventions (wiki Stack Conventions), AGENTS.md, identify scope files
  2. Analyze: For EACH OWASP category → run searches → verify (no false positives) → classify severity
  3. Multi-Tenant: only when row Tenancy = yes — check ALL queries filter by the recorded tenant key, ID from the auth context
  4. Report: Calculate score, group by severity, create security-report.md

Output Template

# Security Audit Report

**Date:** [date] | **Scope:** [path]

## Score

| Category | Status | Findings |
|----------|--------|----------|
| Access Control | ✅/⚠️/❌ | X |
| Crypto | ✅/⚠️/❌ | X |
| Injection | ✅/⚠️/❌ | X |
| Auth | ✅/⚠️/❌ | X |
| Config | ✅/⚠️/❌ | X |
| XSS | ✅/⚠️/❌ | X |
| Deps | ✅/⚠️/❌ | X |
| **OVERALL** | **⚠️** | **X** |

## Critical Findings

### Finding #1
**Category:** [OWASP] | **Severity:** 🔴 | **File:** `path:line`

**Vulnerable Code:** [code]
**Impact:** [simple language]
**Recommendation:** [fix]

## Positive Points
- [good practices found]

## Priority Actions
1. [most urgent]
2. [second]
3. [third]

Rules


False Positive Prevention

Stack-specific protections (NestJS sanitization, Kysely parametrization, React escaping, etc.) and accepted patterns (e.g. process.env.NODE_ENV, internal .raw(), validated PartialType): consult the project's conventions (wiki), then AGENTS.md, for the project's stack and documented exceptions.

Project patterns:

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.