Skip to content
Back to skills

Security Audit

ASecurity

Audit a codebase for security issues and write an evidence-based report: every finding has a file:line, a code excerpt, an attack path, a severity and a fix. Use this whenever the user asks for a security review, security audit or vulnerability audit, asks \"is this safe?\" / \"is my app secure?\" / \"can this be hacked?\", wants pre-release or production hardening, or raises auth, session, token, cookie, CORS, CSP, XSS, CSRF, injection, SSRF, secrets, webhook or access-control concerns — on ...

  • 2 stars
  • 0 votes
  • 2 copies
  • 26 views
  • Added November 30, 2026
developmenttypescriptrustgoshellbashsqlreactvuenextjsnode

Works with

  • api

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned November 30, 2026

npx -y skills add nrimen/clean-code-skills --skill security-audit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Security Audit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Security Audit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nrimen-security-audit/badge)](https://www.skillsdirectory.com/skills/nrimen-security-audit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: security-audit
description: "Audit a codebase for security issues and write an evidence-based report: every finding has a file:line, a code excerpt, an attack path, a severity and a fix. Use this whenever the user asks for a security review, security audit or vulnerability audit, asks \"is this safe?\" / \"is my app secure?\" / \"can this be hacked?\", wants pre-release or production hardening, or raises auth, session, token, cookie, CORS, CSP, XSS, CSRF, injection, SSRF, secrets, webhook or access-control concerns — on a branch, folder or whole repo. Strongest on web, Node.js and TypeScript projects (React, Next.js, Express, Fastify, Nest, PostgreSQL). Not for writing exploits or attack payloads, pentesting or scanning live systems, or auditing code the user doesn't have in front of you. For a quick pre-merge check of one change, code-review is enough."
---

# Security Audit

Find real, exploitable security problems in the code and say clearly how bad each one is and how to fix it. The audit is **read-only**: never edit, delete, commit or push, never run destructive commands, and never contact external hosts or test a live system. The only file this skill writes is the report.

This skill pairs with `code-review`, which catches security issues in a single change before merge. Use `security-audit` for an in-depth pass over the whole attack surface: before a release, after a big feature, or when the user asks specifically about security.

A useful audit is one the user trusts: a short list of confirmed problems with proof beats a long list of maybes. Theoretical issues with no plausible attack path don't belong in the findings.

## 1. Pick the scope

Use the first that applies:
1. The user named files, a folder or the whole repo → use that.
2. Git repo on a feature branch → files changed vs the base branch (`main`, else `master`, else `develop`; use `origin/<name>` if there is no local branch): `git diff --name-only --diff-filter=d <base>...HEAD` (deleted files excluded), plus uncommitted and untracked files (`git status --porcelain`).
3. On the base branch itself, or the branch diff is empty → the whole repo. (Unlike the design audits, a security audit with nothing to diff is usually a pre-release check.)
4. Not a git repo, or nothing found → ask the user what to audit.

Always skip: generated code, lockfiles (but read them for dependency checks), vendored/third-party code, build output, and test fixtures, unless they contain real secrets.

Security depends on context outside the scope, so always read the code a scoped file trusts or is trusted by: the auth middleware in front of a route, the validator before a query, the config that sets cookies or CORS. Report only on the scope, with two exceptions that are always reported wherever they are: committed secrets and secrets in git history.

**Large scope** (whole repo or 50+ code files): map the attack surface first (step 2), then audit in depth what an attacker can reach: entry points, auth, data access, uploads, webhooks, config. State in the report what was covered and what wasn't.

## 2. Map the stack, trust boundaries and attack surface

Run from the repo root (the scripts live in this skill's `scripts/` folder; each takes the path to scan, default `.`, and has `--help`):

```bash
bash scripts/list_attack_surface.sh <path>
```

It lists the detected stack, route and API handlers (Next.js, Express, Fastify, Nest, Koa, Hono), server actions, forms and uploads, webhook handlers, WebSocket/WebRTC/MQTT/SSE endpoints, third-party scripts, environment variables and deployment/CI config. From that and a read of the entry points, write down:
- **Entry points:** every place untrusted input arrives (HTTP routes, forms, uploads, webhooks, sockets, message queues, URL parameters read by the frontend, `postMessage`).
- **Trust boundaries:** browser ↔ server, server ↔ database, server ↔ third-party APIs, tenant ↔ tenant, user ↔ admin.
- **Out of scope:** what you won't review and why (infrastructure not in the repo, closed-source services, live configuration).

## 3. First pass with the scripts: leads, not findings

```bash
bash scripts/scan_secrets.sh <path>
bash scripts/scan_dangerous_patterns.sh <path>
```

`scan_secrets.sh` looks for key and token patterns, private keys, credentialed connection strings, tracked `.env` and key files, and secrets in git history; matches are masked. `scan_dangerous_patterns.sh` greps for risky sinks and settings (`eval`, `dangerouslySetInnerHTML`, shell execution with variables, SQL built by concatenation, `rejectUnauthorized: false`, wildcard CORS, disabled CSRF, tokens in `localStorage`, and more).

**Script output is never a finding by itself.** Open every hit, follow the data back to its source, and decide: is the input attacker-controlled, is there a mitigation upstream, is the code reachable? Most hits are false positives; drop them silently. A grep can't see missing checks (no auth on a route, no ownership check, no signature verification), so the manual walk in step 4 matters more than the scripts.

If a script fails (not a git repo, unusual layout), note it and continue manually.

## 4. Walk the checklists

Load each checklist that matches the stack, and work through it against the entry points from step 2:

| Load | When |
|---|---|
| `references/checklist-frontend.md` | Any browser code: React, Next.js, Vue, plain HTML/JS, browser extensions |
| `references/checklist-backend.md` | Any server code: API routes, server actions, workers, webhooks, WebSocket/MQTT servers |
| `references/checklist-auth-session.md` | Login, sessions, JWT, cookies, OAuth/OIDC, roles, permissions, multi-tenancy (almost always) |
| `references/checklist-data-and-secrets.md` | Databases, personal data, encryption, logs, and whenever `scan_secrets.sh` reports anything |
| `references/checklist-infra-and-config.md` | Dockerfiles, CI workflows, CORS/headers config, `package.json` and lockfiles, deployment config |

Checklists are prompts for attention, not forms to fill in. Spend the time where untrusted input meets something powerful.

## 5. Rate and tag each finding

Read `references/severity-rubric.md` before assigning severity, and `references/owasp-mapping.md` to tag each finding with its OWASP Top 10 (2021) category and CWE.

Severity: 🔴 **Critical** · 🟠 **High** · 🟡 **Medium** · 🔵 **Low** · ⚪ **Info**. It combines how easy the attack is, what it gains, and what privileges it needs. When unsure between two levels, pick the lower one and say why.

Confidence, one per finding:
- **Confirmed:** you traced untrusted input to the vulnerable sink (or the weak setting to production) in the code.
- **Likely:** the path exists in the code, but one link depends on something you can't see (runtime config, a proxy, an external service). Say which link.

Where each issue goes:
- **Findings:** Confirmed or Likely, with a plausible attack path.
- **Hardening recommendations:** good practice that is missing, but with no attack path today (no CSP on a site that renders no untrusted content, a missing security header). Not counted as findings.
- **Needs verification:** suspicions you could not support with evidence from the code.

One finding = one fix: several locations solved by the same change are one finding that lists all of them. Count each issue under the one category it fits best.

## 6. Hard rules

- **Evidence or it isn't a finding.** Every finding has a `file:line` range, a short code excerpt (a few lines), and the reason it is exploitable: what input, from whom, reaching what. Without that, it goes under *Needs verification*.
- **Never print a real secret.** Not in the report, not in the chat. Show its type, file and line, and at most its first 4 characters followed by `***`. Any committed real secret, including one only in git history, gets a recommendation to **rotate** it: deleting the file does not un-leak it.
- **No theoretical issues.** If you can't describe a plausible attacker and path, it's hardening at most.
- **Separate where the problem lives.** Application code, dependencies and configuration each get their own label in the findings table; a vulnerable dependency is not an application-code bug, and its fix is different.
- **Read-only and offline.** Don't edit files, install packages, run the app, call external URLs or probe live systems. That includes `npm audit` and similar tools, which query a remote advisory database: check dependencies by reading the manifest and lockfile, list the known-CVE check under coverage gaps, and tell the user to run `npm audit` (or their package manager's equivalent) themselves.
- **State the gaps.** Say what you did not review (runtime config, infrastructure outside the repo, dependencies you couldn't check, code skipped for size) so a clean report isn't over-trusted.

## 7. Write the report

Write the report to `security-audits/<scope>-<YYYY-MM-DD>.md`, placed at the repo root unless the project already has a reports folder (put it there) or the user names a location. `<scope>` is the branch name, else the audited folder or file name, else `repo`; replace `/` with `-` and append `-2`, `-3`… if the file exists. Don't edit `.gitignore`; mention once that the user can ignore the folder if they don't want reports committed.

Use `assets/report-template.md` exactly. It contains: executive summary with risk posture, scope and methodology, coverage gaps, findings table, detailed findings (description, evidence, attack scenario, impact, remediation with a minimal code example, effort), hardening recommendations, needs verification, positive observations, and a prioritized remediation plan (quick wins first). Omit a section's body with "None." rather than deleting the heading, so readers see it was checked.

Order findings by severity, then confidence, then file. Keep fixes concrete and incremental: the smallest change that closes the hole, not a rewrite.

After saving, reply in chat with: the report path, the risk posture, the count per severity, and the top one to three issues in a sentence each. Keep the chat reply short; the detail lives in the file.

Files in this skill

  • SKILL.md10 KB
  • assets/report-template.md5 KB
  • references/checklist-auth-session.md5.9 KB
  • references/checklist-backend.md7.3 KB
  • references/checklist-data-and-secrets.md4.4 KB
  • references/checklist-frontend.md5.7 KB
  • references/checklist-infra-and-config.md4.7 KB
  • references/owasp-mapping.md5.9 KB
  • references/severity-rubric.md3.3 KB
  • scripts/list_attack_surface.sh8.7 KB
  • scripts/scan_dangerous_patterns.sh13.3 KB
  • scripts/scan_secrets.sh10 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.