# Security Audit

> Runs a full, end-to-end, read-only security audit of an entire codebase — cross-ecosystem dependency vulnerability scanning with per-advisory runtime-exposure analysis (not raw scanner output), a whole-codebase OWASP-style code sweep, an SBOM, and a separate sweep for stale/EOL runtimes and deprecated APIs beyond just CVEs — producing one report where every finding is classified by severity and urgency (fix immediately / fix soon / track only), with the reasoning behind each. This skill finds and classifies; it never applies a fix itself — remediation is a separate, explicit hand-off to `incremental-implementation` (or `subagent-driven-development` for larger work), which owns the actual build/test/regression discipline. Use when asked to "audit security on this codebase", "run a security audit", "check for vulnerabilities across the whole repo", or "what security upgrades do we need".

- Skill: `ghosteken/security-audit` (Agent Skill)
- Install (CLI): `npx get-skill add ghosteken/security-audit`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ghosteken/security-audit/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: Ghosteken (https://skillmd.com/u/ghosteken)
- Updated: 2026-11-11
- Page: https://skillmd.com/skills/ghosteken/security-audit

---


# Security Audit

## Overview

A real security audit isn't "run a scanner, upgrade whatever it flags." It's: find every real finding (dependency CVEs *and* code-level issues *and* stale runtimes), decide for each one whether it's actually reachable in this specific codebase, and classify it — severity, and a concrete urgency call: fix immediately, fix soon, or track and leave for now, each with the reasoning behind it. That's the whole deliverable. This skill is purely diagnostic — it never edits code, bumps a dependency, or touches a lockfile itself. Acting on a finding is a separate task for `incremental-implementation` (small, independent fixes) or `subagent-driven-development` (larger remediation work), which already own the implement → test → verify → regression-check discipline this kind of change needs; re-deriving that discipline here would just duplicate it. This skill leans on `security-and-hardening` and `references/security-checklist.md` for the underlying checklists rather than re-deriving them, and adds the parts neither of those cover on their own at whole-codebase scale: cross-ecosystem dependency-CVE triage with exposure reasoning, an SBOM, and a dedicated stale-runtime/deprecated-API/CI-hygiene sweep.

## When to Use

- Asked to audit, review, or check security across an entire codebase or repo — not just the current diff
- Asked "what security upgrades do we need" or "are we behind on anything security-relevant"
- Periodic/scheduled security hygiene pass, or before a release
- **NOT** for reviewing one pending change's security — that's `code-review`'s Security section or `security-and-hardening` applied during the change itself
- **NOT** for designing security into a feature being built — that's `security-and-hardening`'s own primary use case
- **NOT** for actually fixing anything this audit finds — that's `incremental-implementation`/`subagent-driven-development`, once this skill has told them what needs fixing and why

## Keep This Efficient — a Whole-Codebase Audit Can Burn Tokens Fast If Done Wrong

Three rules apply across every step below, because this skill's own scope (the whole codebase, not a diff) makes it easy to blow through a large token budget on busywork rather than real findings:

1. **Prefer a real tool's output over reading files by hand.** A dependency scanner, a SAST tool (Semgrep, CodeQL, Bandit, `eslint-plugin-security`, `gosec`, Brakeman — whatever this ecosystem has), and an SBOM generator are all far cheaper than an agent reading the entire codebase file-by-file against a checklist, and more consistent besides. Run the tool first; only read source directly to confirm or dismiss a *specific* candidate the tool already surfaced, or for a risk category no available tool covers for this ecosystem.
2. **Never paste raw tool output into the conversation.** `npm audit --json`, a full SBOM, or a SAST tool's raw findings file can run to thousands of lines — write it to a file and parse/`grep` out only the fields the triage in Steps 3-4 actually needs (ID, severity, package, patched version, file:line). The report cites the parsed, relevant fields; it never reproduces the tool's full dump.
3. **Scale effort to severity, not to how many advisories exist.** A `low`-severity advisory with no known exploitability gets a quick batched entry (package, advisory ID, one-line scanner rationale) in the Track Only table — it does not get the same individual reachability trace as a moderate-or-higher one. Spending equal effort on every advisory regardless of severity is how a 200-advisory `npm audit` output turns a 20-minute audit into a multi-hour one for no extra safety.

## Process

### 1. Scope the audit, from a fixed reference point

Determine what's in scope: the whole repo, or a specific package/service if the user named one. State exactly what was audited — a specific commit, tag, or branch — not a moving `HEAD` someone could push to mid-audit; the report is only meaningful if it's reproducible against a named point. List **every** dependency manifest and lockfile in scope — a monorepo may have several services each with their own `package.json`, and a single service can have more than one lockfile resolving it (e.g. `package-lock.json` for CI's `npm ci` alongside a `yarn.lock` a separate deploy workflow actually installs from — check which workflow/Dockerfile/CI config installs with which tool, don't assume only one lockfile matters just because it's the one most recently touched). Note this now, in the report, as a fact the eventual fix will need to account for — not something this skill itself needs to reconcile.

### 2. Run dependency vulnerability scanning, per ecosystem found

For each ecosystem in scope, run its real scanner — see `references/library-reuse.md`'s "Dependency vulnerability scanning" row for the current tool per ecosystem (`npm`/`pnpm audit`, `pip-audit`, `dotnet list package --vulnerable`, `govulncheck`, etc.). Redirect its output to a file (`--json > audit.json` or equivalent) and parse out just ID (CVE/GHSA), severity, affected package and version range, and patched version — never let a hundreds-of-lines scanner dump land directly in the conversation. Don't stop at the first ecosystem if the repo has more than one.

### 3. Triage every advisory by actual exposure — never take scanner severity at face value

This is the step that separates a real audit from a checkbox exercise. For every moderate-or-higher advisory, apply `security-and-hardening`'s "Triaging npm audit Results" decision tree (generalized beyond npm to whatever ecosystem's scanner flagged it): is the vulnerable function/feature actually reachable from this app's code, is the dependency a runtime dependency or dev/build-only tooling, does the deployment context even expose the vulnerable path (e.g. a vulnerability in server-side image transforms doesn't apply if the app never serves that route). State the exposure conclusion explicitly for each advisory — applies / possible / low exposure / not used — the same way a senior engineer would write it up, not just repeating the scanner's own severity label. A dependency pulled in only by a dev-only tool (a linter, a test runner, a CSS-import-only package never executed at runtime) is a different exposure category than one actually running in production, and the audit says so per advisory, not as a blanket assumption.

**The package merely being present (imported/installed) is not the same as the vulnerable code path being reachable.** Presence-in-the-dependency-graph is a first filter, not a verdict — grep for actual usage of the vulnerable function/feature, and where it's genuinely unclear, trace whether attacker-controlled input can actually reach that call, not just whether the package is in `node_modules`/`site-packages`/etc. somewhere. Two further things override a plain CVSS-severity read:
- **Known-exploited status raises urgency regardless of CVSS.** A `moderate`-rated advisory already listed in CISA's Known Exploited Vulnerabilities (KEV) catalog, or with public exploit code circulating, gets treated as higher-urgency than its raw score suggests.
- **Escalate findings that touch authentication, secrets, service accounts/credentials, or internet-facing endpoints** — these categories warrant higher urgency even at borderline exposure, since the blast radius of a wrong call is much higher there than in an internal admin-only tool.

### 4. Classify every finding: severity, and a concrete urgency call

For every finding from this point forward — dependency advisories, and the Step 6/7 sweeps below — give it two explicit labels, not just one:
- **Severity** — high / medium / low, informed by the scanner's rating but adjusted by Step 3's exposure conclusion (an exposure-confirmed critical stays high; a `critical`-rated advisory on a dev-only, never-executed dependency is downgraded, with the reasoning stated).
- **Urgency** — **fix immediately** (exposure confirmed, high severity, or KEV-listed/actively exploited), **fix soon** (applies but lower severity, or exposure is plausible but unconfirmed), or **track only / can leave for now** (not exploitable in this deployment, dev-only, or genuinely low-impact) — each with the one-line reasoning that justifies it, the same way Step 3's exposure conclusion is never left implicit.

This classification is the actual deliverable of the audit — a finding without both labels, or with a label and no reasoning, isn't done yet.

### 5. Generate or refresh the SBOM

Produce (or update) a software bill of materials — CycloneDX or SPDX, whichever this project/ecosystem's tooling already supports — covering **transitive** dependencies, not just direct ones; most supply-chain compromises sit several levels deep, and an SBOM that only lists top-level packages misses exactly those. This is what lets a future "is this new CVE affecting us" question get answered in minutes instead of re-running a full audit. If the project already has a signed/provenance build pipeline, note that the SBOM should be bound to that build rather than generated as a disconnected artifact; if it doesn't, generating the SBOM as a standalone visibility artifact is still worth doing, just say so.

**Save the generated file to `security-audits/<YYYY-MM-DD>-sbom.<cdx.json|spdx.json>` at the project's external output location (see `references/external-output-paths.md`) — the same external location as the audit report itself, never a path inside this project's own repository, not even a gitignored one.** Most SBOM tools default to writing into the current directory when run — redirect their output explicitly rather than letting that default land the file in the repo. The one exception: if this project's build pipeline already has its own established convention for where SBOMs live (e.g. already wired into an existing release workflow), follow that existing convention instead of inventing a second location — but that's an existing, discoverable convention to confirm, not a default to assume.

### 6. Run the whole-codebase SAST-style sweep — tool first, not a manual read-through

Beyond dependency CVEs, check the **existing** codebase (not just a diff) against `security-and-hardening`'s OWASP Top 10 Prevention Patterns and `references/security-checklist.md`'s checklist — hardcoded secrets, auth/authz gaps, injection surfaces, SSRF, insecure deserialization, missing rate limiting, and the rest. **Run an actual static-analysis tool for this ecosystem first** (Semgrep, CodeQL, Bandit, `eslint-plugin-security`, `gosec`, Brakeman, or whatever this language has) — write its output to a file and parse out the real findings, per the efficiency rules above. Reading source directly is for two narrower cases only: confirming or dismissing a specific tool-flagged candidate, and the handful of risk categories no available tool covers well for this ecosystem (business-logic authz gaps are the common one) — scope that manual look to the files most likely to matter (auth, API entry points, data-access boundaries), not a linear read of the entire repo. This is a standing audit of what's already there, not a review of what just changed — apply the same checklist `security-and-hardening` already defines rather than inventing a parallel one. Classify every finding here the same way Step 4 does (severity + urgency + reasoning) — this sweep isn't exempt from that just because it's code-level rather than a dependency advisory.

### 7. Sweep for upgrades needed beyond CVEs, and CI/build supply-chain hygiene

Check for what a CVE scanner won't tell you: a runtime (Node/Python/.NET/etc.) version approaching or past its own EOL/LTS cutoff, a major framework version behind current with its support window closing, deprecated APIs still called that a current major version has already removed or scheduled for removal. This is the "or upgrades needed" half of a real audit — not every finding here needs a CVE behind it to be worth flagging, and each still gets Step 4's severity + urgency classification.

Also check the build/CI pipeline itself, extending `security-and-hardening`'s "Supply-Chain Hygiene" subsection to the pipeline that produces the build, not just the app's own dependencies: CI dependencies and GitHub Actions (or equivalent) pinned to a commit SHA rather than a mutable tag, base images pinned to a digest rather than a floating tag, and the build identity/service account running with least privilege (a build identity that can read production data or secrets it doesn't need is itself a finding). A minimum package age or disabling install scripts by default are both worth noting as options — not a mandatory fix this skill applies, just a finding for whoever does the remediation to weigh against the project's actual build needs.

### 8. Produce the structured report

Shape the output around the classification, not a bare list of advisories:

```markdown
## Security Audit Report

**Scope:** <commit/tag/branch audited>

### Fix Immediately
| Finding | Severity | Source | Reasoning |
|---|---|---|---|
| <CVE/GHSA id, or code-level/upgrade finding> | high | dependency / code sweep / upgrade sweep | <exposure/reachability/KEV reasoning> |

### Fix Soon
| Finding | Severity | Source | Reasoning |
|---|---|---|---|

### Track Only / Can Leave For Now
| Finding | Severity | Source | Reasoning |
|---|---|---|---|

### What a Fix Needs to Account For
- Lockfiles that must all stay in sync for any dependency change (from Step 1)
- The minimum-version-bump target per advisory (not "latest") and this project's existing pinning/range convention
- Any advisory that would require a major-version bump — flag it as a bigger decision than the security fix itself, for whoever picks this up to confirm separately

### SBOM
- <full saved path at the external output location, and whether it's bound to a signed build or a standalone visibility artifact>

### Suggested Process Follow-ups
- <gaps that let this happen — e.g. standardize on one package manager, add CI dependency pinning, add missing input bounds>
```

This skill made no code or dependency changes — so the report is always a saved artifact, not a PR description. Save it to `security-audits/<YYYY-MM-DD>-audit.md` in the project's external output location (see `references/external-output-paths.md`), and tell the user the full path.

### 9. Hand off — remediation is a separate task

State plainly that fixing anything in the "Fix Immediately"/"Fix Soon" tables is the next step, not something this run also does. Point to `incremental-implementation` for an independent fix (or a small batch of related ones) — it already owns writing the test, verifying the lockfile(s) stay consistent, running build/lint/test, and the mandatory live `quality-assurance` pass before calling anything done. For remediation large enough to span several independent pieces of work, point to `subagent-driven-development` instead. If a real process/architecture decision came out of the audit (e.g. standardizing package managers), point to `documentation-and-adrs` for that decision, separately from the code fix itself.

## Common Rationalizations

| Rationalization | Reality |
|---|---|
| "The scanner flagged it, I'll just upgrade it" | A scanner has no idea whether the vulnerable path is reachable in your app — trace exposure first; an unreachable dev-only dependency doesn't need the same urgency as a runtime dependency on a live request path. |
| "I found this, I'll just fix it while I'm here" | This skill is read-only by design — finding and fixing are different tasks with different disciplines (fixing needs the test/build/regression loop `incremental-implementation` owns). Report the finding and its urgency; hand the fix off. |
| "No CVE was flagged, so there's nothing to report here" | A stale runtime approaching EOL or a deprecated API still in use is a real finding worth flagging even with no CVE attached — that's the explicit purpose of Step 7. |
| "I'll just note this finding is 'low risk' without explaining why" | A classification needs the actual reasoning stated (not exploitable because X, dev-only because Y) — a severity/urgency label with no justification is indistinguishable from not having checked at all. |
| "Severity from the scanner is enough, I don't need a separate urgency call" | Severity and urgency are different questions — a `critical` advisory on an unreachable dev-only dependency doesn't need the same response as a `moderate` one on an internet-facing auth endpoint. Both labels, every time. |
| "The package is imported somewhere, so the advisory applies" | Presence in the dependency graph is a first filter, not proof — confirm the vulnerable function is actually called with input that could realistically be attacker-controlled before calling it "applies." |
| "It's only moderate severity, I'll call it track-only" | Check known-exploited (KEV) status and exposure category first — a moderate-rated advisory already being actively exploited, or touching auth/secrets/service accounts, gets a higher urgency call than its raw CVSS score alone suggests. |
| "An SBOM is extra paperwork, the audit is already done without it" | An SBOM is what lets the *next* CVE disclosure be answered in minutes instead of re-running this whole audit — it's part of the deliverable, not an optional add-on, and it should cover transitive dependencies, not just direct ones. |
| "I'll read through the codebase myself for the SAST sweep, it's more thorough" | A real static-analysis tool is both cheaper and more consistent than a manual file-by-file read — run the tool first; reserve manual reading for confirming specific flagged candidates or the few risk categories no tool covers. |
| "I'll paste the full scanner/SBOM output so nothing's lost" | Redirect it to a file and parse out only the fields the triage needs — a raw dump in the conversation burns a large amount of budget for information the report never actually uses verbatim. |
| "Every advisory deserves the same careful reachability trace" | Scale effort to severity — a `low` advisory gets a quick batched Track Only entry, not the same individual trace as a moderate-or-higher one; equal effort on all of them is how a long advisory list turns a short audit into a very expensive one. |

## Red Flags

- A dependency bumped, a lockfile touched, or any code edited by this skill directly — it's read-only; that's `incremental-implementation`'s job
- A finding with no stated reasoning about whether the vulnerable path is actually reachable in this app
- A finding with a severity label but no separate urgency call (fix immediately / fix soon / track only), or either one with no reasoning
- A report with no "Track Only" section when the scan clearly surfaced lower-urgency findings alongside the fixed-now ones
- No mention of stale runtime versions or deprecated APIs at all, on an audit that's supposed to cover "or upgrades needed"
- The whole-codebase OWASP sweep skipped entirely, treating this as a dependency-only audit when the skill's own scope is end-to-end
- "Applies" declared from the package merely being present/imported, with no check of whether the vulnerable call path is actually reachable
- A moderate-severity advisory marked track-only without checking known-exploited (KEV) status or whether it touches auth/secrets/an internet-facing endpoint
- No SBOM generated or refreshed, or one that only lists direct dependencies and skips transitive ones
- The SBOM (or the audit report) written inside the project's own repository — even a gitignored path — instead of the external output location
- The audit scoped to a moving branch/HEAD with no named commit, tag, or release point stated
- CI/build pipeline hygiene (pinned Actions/base images, build-identity privilege) never checked, treating the audit as app-dependencies-only
- No explicit hand-off statement pointing at `incremental-implementation`/`subagent-driven-development` for the actual fix work
- The SAST sweep done as a manual file-by-file read with no static-analysis tool run first, for an ecosystem that has one
- Raw scanner/SBOM/tool output pasted directly into the conversation instead of redirected to a file and parsed
- Every advisory (including low-severity ones) given the same individual reachability trace instead of scaling effort to severity

## Verification

- [ ] This run made no code, dependency, or lockfile changes — it only scanned, triaged, classified, and reported
- [ ] Every dependency manifest and lockfile in scope was identified, including ones a separate CI/deploy pipeline installs from that local tooling doesn't normally touch
- [ ] Every ecosystem present was scanned with its real vulnerability-scanning tool, not just the first one found
- [ ] Every moderate-or-higher advisory has a stated, reasoned exposure conclusion (applies/possible/low/not used) — not the scanner's severity repeated verbatim
- [ ] Every finding (dependency, code-sweep, and upgrade-sweep) has both a severity label and an urgency call (fix immediately/fix soon/track only), each with reasoning
- [ ] The whole-codebase OWASP-style sweep (Step 6) and the stale-runtime/deprecated-API/CI-pinning sweep (Step 7) both actually ran, not just the dependency-CVE part
- [ ] Known-exploited (KEV) status and auth/secrets/internet-facing exposure were checked before marking anything below high severity as track-only
- [ ] An SBOM was generated or refreshed, covering transitive dependencies, saved to the external output location (never inside the project's own repo), with its path told to the user
- [ ] The audit states the exact commit/tag/branch it was scoped to, not a moving `HEAD`
- [ ] The report was saved to `security-audits/<YYYY-MM-DD>-audit.md` at the external output location, with the full path told to the user
- [ ] The SAST sweep ran a real static-analysis tool first where one exists for this ecosystem, with manual reading scoped to specific flagged candidates or uncovered risk categories only
- [ ] No raw scanner/SBOM/tool output was pasted directly into the conversation — all of it was redirected to a file and parsed for just the needed fields
- [ ] Effort scaled to severity — low-severity advisories got a quick batched entry, not the same individual reachability trace as moderate-or-higher ones
- [ ] The report ends with an explicit hand-off to `incremental-implementation` (or `subagent-driven-development`) for remediation, not an implication that fixing is this run's job too

## See Also

- `security-and-hardening` — the OWASP Top 10 checklist and the "Triaging npm audit Results" decision tree this skill applies at whole-codebase scale
- `references/security-checklist.md` — deeper reference for the Step 6 code-level sweep
- `references/library-reuse.md` — per-ecosystem dependency vulnerability scanning tools (and secret detection, for a `project-scaffolding` cross-reference)
- `code-review` — reviews security concerns in a single pending diff; this skill audits the whole existing codebase instead
- `incremental-implementation` / `subagent-driven-development` — where remediation of this audit's findings actually happens, with the build/test/regression discipline that needs
- `documentation-and-adrs` — for a process/architecture decision the audit surfaces (e.g. standardizing package managers), separate from the code fix itself
- `references/external-output-paths.md` — where the audit report is saved

