Dependency Audit — Framework, Package, and Toolchain Security
Audit project dependencies, frameworks, language runtimes, and dev tools for known vulnerabilities (CVEs), security anti-patterns, and supply chain risks.
Methodology
Step 1: Inventory the Stack
Identify everything in use — not just direct dependencies but the full chain:
Package manifests — read and catalog:
Node/JS: package.json, package-lock.json, yarn.lock, pnpm-lock.yaml
Python: requirements.txt, Pipfile.lock, pyproject.toml, poetry.lock
Ruby: Gemfile, Gemfile.lock
Go: go.mod, go.sum
Rust: Cargo.toml, Cargo.lock
Java: pom.xml, build.gradle
PHP: composer.json, composer.lock
.NET: *.csproj, packages.config
Framework and runtime versions:
- Check framework version (Next.js, Django, Rails, Spring, Laravel, Express, etc.)
- Check language/runtime version (Node.js, Python, Ruby, Go, Java, PHP, .NET)
- Check infrastructure tools (Docker base images, Terraform providers, Kubernetes versions)
Dev tools and CI/CD:
- Check CI/CD pipeline configs (.github/workflows, .gitlab-ci.yml, Jenkinsfile)
- Check pre-commit hooks, linters, formatters
- Check container base images and their update status
- Check IaC tool versions (Terraform, Pulumi, CDK)
Edge cases in package manifests:
optionalDependencies — installed but not audited by default
peerDependencies — version range may not match what's installed
overrides / yarn resolutions / pnpm overrides — check if used to silence advisories rather than fix them
- Monorepos: read every
packages/*/package.json and apps/*/package.json, not just the root
engines field — older-than-LTS Node makes other audits moot
Step 2: Run Automated Audit Tools
Run the appropriate audit command for the project:
# Node.js
npm audit --json # full structured output
npm audit --omit=dev --json # production-only: filters dev/build-time vulns
# Compare the two — vulns only in dev/build tooling do not ship to users
# and should be triaged as lower priority. Don't bury this in the report.
# Python
pip audit # If pip-audit installed
safety check # If safety installed
# Ruby
bundle audit
# Go
govulncheck ./...
# Rust
cargo audit
# PHP
composer audit
# .NET
dotnet list package --vulnerable
# Docker
docker scout cves <image>
trivy image <image>
# General (if Trivy is available)
trivy fs .
Applying fixes — read before you --force:
npm audit fix # safe: upgrades within stated ranges
npm audit fix --dry-run --force # ALWAYS dry-run first
npm audit fix --force # only after reviewing the dry-run
npm audit fix --force can resolve an advisory by DOWNGRADING a package to an older version that doesn't trigger the audit signature. This is almost always wrong (e.g. downgrading next@16 to next@9 to "fix" a transitive postcss CVE). Inspect dry-run output for "Will install X@Y, which is a breaking change" — that's the tool trying to downgrade.
When npm audit fix cannot resolve an advisory (transitive dep pinned by an upstream package):
- Determine reachability — is the vulnerable code path actually invoked in your usage?
npm ls <package> + reading the parent's source can rule it out as unreachable.
- Consider a
package.json overrides pin to a patched version (test thoroughly — overrides can break the parent).
- Consider swapping the parent provider entirely.
- If none apply: document explicitly, track upstream, and note in the audit report rather than silently dropping the finding.
Step 3: Research Framework-Specific Known Issues
Beyond CVEs in packages, check for known vulnerability patterns specific to the framework in use. Search for recent advisories and common misconfiguration issues.
For every direct dependency, cross-reference the installed version against:
https://github.com/advisories?ecosystem=npm&query=<package>
https://github.com/<org>/<repo>/security/advisories
The framework-specific patterns below cover evergreen anti-patterns (mass assignment, debug-in-prod, etc.). Recent CVEs need a fresh check because hardcoded advisory lists rot fast and LLM training data is often 6+ months behind the latest.
Next.js / React:
- Server Actions exposing internal endpoints (pre-14.1.1 middleware bypass CVE-2025-29927)
dangerouslySetInnerHTML without sanitization
- SSRF through image optimization (
next/image with unrestricted domains)
- Exposed
.env files in public directory or client bundle (NEXT_PUBLIC_ prefix leaking secrets)
- Middleware auth bypass patterns — check middleware.ts matches all protected routes
- Server Component / Client Component boundary leaking server-only data:
- Any module reading
process.env.SECRET or instantiating a DB client should start with import "server-only"; — fails the build if imported from a Client Component
- Grep for: files in
lib/ that touch process.env.[A-Z_]+ but do NOT import server-only
- Inverse check: any file with
"use client" importing from such a module is a leak
- Outdated
next.config.js security headers
Django:
- DEBUG=True in production
- ALLOWED_HOSTS misconfigured (wildcard
*)
- Missing CSRF middleware or
@csrf_exempt on state-changing views
- Raw SQL via
extra(), raw(), or RawSQL without parameterization
- Pickle deserialization in sessions (use JSON serializer)
- Secret key committed to source control
Rails:
- Mass assignment without strong parameters
- SQL injection via
where("column = '#{input}'")
- Unpatched Action Pack, Action View, or Active Record CVEs
- Insecure deserialization in cookies (verify secret_key_base rotation)
- CSRF token bypass in API-only mode
Express / Node.js:
- Prototype pollution through
Object.assign, lodash.merge, deep-extend
- ReDoS (Regular Expression Denial of Service) in validation patterns
- Path traversal through
req.params in file serving routes
- Missing rate limiting on auth endpoints
eval() or Function() with user input
- Event loop blocking with synchronous operations
Serverless / edge runtimes (Vercel, Lambda, Cloud Run, Workers):
- In-memory state ≠ rate limit. A module-scoped
Map or Set for rate limiting, sessions, or caches is per-instance. Cold starts reset state; load spreads across instances; attackers bypass trivially.
- Grep for:
const rateLimitMap = new Map, const cache = new Map in server-action / API-route files
- Fix: shared store — Vercel KV, Upstash Ratelimit, Redis, DynamoDB
- Unbounded in-memory collections leak memory under traffic. Cap size and evict (LRU or FIFO).
x-forwarded-for trust: only trustworthy when the edge overwrites it. Behind misconfigured proxy chains it's attacker-spoofable. A fallback to a single "unknown" bucket throttles all anonymous traffic together; random-fallback silently disables the limit.
Spring / Java:
- Spring4Shell and related RCE vulnerabilities
- Deserialization attacks (Java native serialization, Jackson polymorphic types)
- SpEL injection in Spring Expression Language
- Missing CSRF protection on state-changing endpoints
- Actuator endpoints exposed without authentication
Laravel / PHP:
- APP_DEBUG=true in production (leaks env vars in error pages)
- SQL injection via raw DB queries without bindings
- Mass assignment without
$fillable / $guarded
- File upload without type validation (PHP execution via uploaded .php)
- Insecure deserialization in queued jobs
WordPress:
- Outdated core, theme, or plugin versions (most common attack vector)
- File editor enabled in wp-admin (allows code injection if admin is compromised)
- XML-RPC enabled (brute force amplification, SSRF)
- Default admin username, weak passwords
- Unpatched plugin vulnerabilities (check WPScan database)
Step 4: Check for Supply Chain Risks
Beyond known CVEs, look for supply chain attack indicators:
Dependency confusion / substitution:
- Private package names that could be claimed on public registries
- Missing
.npmrc or pip.conf scoping to private registry
- No lockfile integrity verification
Typosquatting:
- Package names that are close misspellings of popular packages
- Recently published packages with very few downloads
- Packages that changed ownership recently
Malicious packages:
- Postinstall scripts that make network requests or execute code (
scripts.postinstall in package.json)
- Packages with obfuscated code
- Excessive permission requests relative to functionality
Maintenance risk:
- Unmaintained packages (no commits in 2+ years, archived repos)
- Single-maintainer packages for critical functionality
- Packages with known but unpatched vulnerabilities (maintainer unresponsive)
Lockfile integrity:
- Lockfile committed?
git ls-files | grep -E 'package-lock\.json|yarn\.lock|pnpm-lock\.yaml|Gemfile\.lock|poetry\.lock|composer\.lock|Cargo\.lock|go\.sum'
- CI installs from lockfile?
- Check
.github/workflows/*.yml, .gitlab-ci.yml, Jenkinsfile, vercel.json, netlify.toml, Dockerfile
npm install (bad) vs npm ci (good); yarn install (bad) vs yarn install --immutable (good); pip install -r (bad) vs pip install --require-hashes -r (good)
integrity hashes present in the lockfile? (modern npm/pnpm yes by default)
Step 5: Check Dev Tool and CI/CD Security
GitHub Actions:
pull_request_target trigger with checkout of PR code (code injection risk)
- Secrets accessible in forked PR workflows
- Unpinned action versions (
uses: actions/checkout@main vs @v4.1.0 or SHA pin)
- Script injection via
${{ github.event.issue.title }} in run: blocks
Docker:
- Running as root in container (missing
USER directive)
- Base image with known CVEs (check with
trivy or docker scout)
- Secrets baked into image layers (visible via
docker history)
latest tag instead of pinned version
Terraform / IaC:
- Hardcoded secrets in
.tf files
- Unpinned provider versions
- Missing state file encryption
- Over-permissive IAM in provider configuration
Output Format
# Dependency & Stack Security Audit
## Project: [name]
## Stack: [language, framework, key tools]
## Date: [date]
### Stack Inventory
| Component | Version | Latest | Status |
|-----------|---------|--------|--------|
### Known Vulnerabilities (CVEs)
| Package | Installed | Vuln | Severity | Where reachable | CVE | Fix Version |
|---------|-----------|------|----------|-----------------|-----|-------------|
Where reachable values: `runtime` / `build-only` / `dev-only`. Confirm with `npm ls --omit=dev <package>` or inspect the deployment artifact (Vercel function bundle, Docker layer). Build- and dev-only vulnerabilities should not block a release on their own; runtime-reachable ones should.
### Framework-Specific Issues
#### [SEVERITY] [Title]
**Component:** [framework/tool name and version]
**Issue:** [description]
**Evidence:** [code or config snippet]
**Remediation:** [specific fix]
### Supply Chain Risks
| Risk | Package/Component | Details | Remediation |
|------|-------------------|---------|-------------|
### Dev Tool / CI Security
| Tool | Issue | Severity | Remediation |
|------|-------|----------|-------------|
### Prioritized Action Plan
1. [Critical — actively exploited CVEs, RCE vulnerabilities]
2. [High — known CVEs with public exploits, supply chain risks]
3. [Medium — framework misconfigurations, outdated dependencies]
4. [Low — maintenance risks, best practice improvements]
Boundaries
- Only audit code and configurations the user provides
- When identifying CVEs, verify they apply to the actual installed version
- Provide specific fix versions or remediation steps for every finding
- Note when a vulnerability requires specific conditions to exploit (reducing effective severity)
- Refuse to help exploit found vulnerabilities against unauthorized targets
References
- OWASP Dependency-Check
- National Vulnerability Database (NVD)
- GitHub Advisory Database
- Snyk Vulnerability Database
- npm audit / pip-audit / bundler-audit documentation
- SLSA (Supply-chain Levels for Software Artifacts) framework
1---2name: dependency-audit3description: Audit project dependencies, frameworks, languages, and dev tools for known vulnerabilities, CVEs, and security anti-patterns. Use when the user mentions 'dependency audit,' 'npm audit,' 'CVE,' 'vulnerable packages,' 'supply chain security,' 'outdated dependencies,' 'known vulnerabilities,' 'security advisory,' 'package security,' 'framework vulnerability,' 'is this package safe,' or needs to check whether their stack has known security issues.4---5
6# Dependency Audit — Framework, Package, and Toolchain Security
7
8Audit project dependencies, frameworks, language runtimes, and dev tools for known vulnerabilities (CVEs), security anti-patterns, and supply chain risks.
9
10## Methodology
11
12### Step 1: Inventory the Stack
13
14Identify everything in use — not just direct dependencies but the full chain:
15
16**Package manifests — read and catalog:**
17```
18Node/JS: package.json, package-lock.json, yarn.lock, pnpm-lock.yaml
19Python: requirements.txt, Pipfile.lock, pyproject.toml, poetry.lock
20Ruby: Gemfile, Gemfile.lock
21Go: go.mod, go.sum
22Rust: Cargo.toml, Cargo.lock
23Java: pom.xml, build.gradle
24PHP: composer.json, composer.lock
25.NET: *.csproj, packages.config
26```
27
28**Framework and runtime versions:**
29- Check framework version (Next.js, Django, Rails, Spring, Laravel, Express, etc.)
30- Check language/runtime version (Node.js, Python, Ruby, Go, Java, PHP, .NET)
31- Check infrastructure tools (Docker base images, Terraform providers, Kubernetes versions)
32
33**Dev tools and CI/CD:**
34- Check CI/CD pipeline configs (.github/workflows, .gitlab-ci.yml, Jenkinsfile)
35- Check pre-commit hooks, linters, formatters
36- Check container base images and their update status
37- Check IaC tool versions (Terraform, Pulumi, CDK)
38
39**Edge cases in package manifests:**
40- `optionalDependencies` — installed but not audited by default
41- `peerDependencies` — version range may not match what's installed
42- `overrides` / yarn `resolutions` / pnpm `overrides` — check if used to *silence* advisories rather than fix them
43- Monorepos: read every `packages/*/package.json` and `apps/*/package.json`, not just the root
44- `engines` field — older-than-LTS Node makes other audits moot
45
46### Step 2: Run Automated Audit Tools
47
48Run the appropriate audit command for the project:
49
50```bash
51# Node.js
52npm audit --json # full structured output
53npm audit --omit=dev --json # production-only: filters dev/build-time vulns
54# Compare the two — vulns only in dev/build tooling do not ship to users
55# and should be triaged as lower priority. Don't bury this in the report.
56
57# Python
58pip audit # If pip-audit installed
59safety check # If safety installed
60
61# Ruby
62bundle audit
63
64# Go
65govulncheck ./...
66
67# Rust
68cargo audit
69
70# PHP
71composer audit
72
73# .NET
74dotnet list package --vulnerable
75
76# Docker
77docker scout cves <image>
78trivy image <image>
79
80# General (if Trivy is available)
81trivy fs .
82```
83
84**Applying fixes — read before you `--force`:**
85
86```bash
87npm audit fix # safe: upgrades within stated ranges
88npm audit fix --dry-run --force # ALWAYS dry-run first
89npm audit fix --force # only after reviewing the dry-run
90```
91
92`npm audit fix --force` can resolve an advisory by DOWNGRADING a package to an older version that doesn't trigger the audit signature. This is almost always wrong (e.g. downgrading `next@16` to `next@9` to "fix" a transitive postcss CVE). Inspect dry-run output for "Will install X@Y, which is a breaking change" — that's the tool trying to downgrade.
93
94**When `npm audit fix` cannot resolve an advisory** (transitive dep pinned by an upstream package):
95
961. **Determine reachability** — is the vulnerable code path actually invoked in your usage? `npm ls <package>` + reading the parent's source can rule it out as unreachable.
972. **Consider a `package.json` `overrides` pin** to a patched version (test thoroughly — overrides can break the parent).
983. **Consider swapping the parent provider entirely.**
994. **If none apply:** document explicitly, track upstream, and note in the audit report rather than silently dropping the finding.
100
101### Step 3: Research Framework-Specific Known Issues
102
103Beyond CVEs in packages, check for known vulnerability patterns specific to the framework in use. Search for recent advisories and common misconfiguration issues.
104
105For every direct dependency, cross-reference the installed version against:
106- `https://github.com/advisories?ecosystem=npm&query=<package>`
107- `https://github.com/<org>/<repo>/security/advisories`
108
109The framework-specific patterns below cover *evergreen* anti-patterns (mass assignment, debug-in-prod, etc.). Recent CVEs need a fresh check because hardcoded advisory lists rot fast and LLM training data is often 6+ months behind the latest.
110
111**Next.js / React:**
112- Server Actions exposing internal endpoints (pre-14.1.1 middleware bypass CVE-2025-29927)
113- `dangerouslySetInnerHTML` without sanitization
114- SSRF through image optimization (`next/image` with unrestricted domains)
115- Exposed `.env` files in public directory or client bundle (`NEXT_PUBLIC_` prefix leaking secrets)
116- Middleware auth bypass patterns — check middleware.ts matches all protected routes
117- Server Component / Client Component boundary leaking server-only data:
118 - Any module reading `process.env.SECRET` or instantiating a DB client should start with `import "server-only";` — fails the build if imported from a Client Component
119 - Grep for: files in `lib/` that touch `process.env.[A-Z_]+` but do NOT import `server-only`
120 - Inverse check: any file with `"use client"` importing from such a module is a leak
121- Outdated `next.config.js` security headers
122
123**Django:**
124- DEBUG=True in production
125- ALLOWED_HOSTS misconfigured (wildcard `*`)
126- Missing CSRF middleware or `@csrf_exempt` on state-changing views
127- Raw SQL via `extra()`, `raw()`, or `RawSQL` without parameterization
128- Pickle deserialization in sessions (use JSON serializer)
129- Secret key committed to source control
130
131**Rails:**
132- Mass assignment without strong parameters
133- SQL injection via `where("column = '#{input}'")`
134- Unpatched Action Pack, Action View, or Active Record CVEs
135- Insecure deserialization in cookies (verify secret_key_base rotation)
136- CSRF token bypass in API-only mode
137
138**Express / Node.js:**
139- Prototype pollution through `Object.assign`, `lodash.merge`, `deep-extend`
140- ReDoS (Regular Expression Denial of Service) in validation patterns
141- Path traversal through `req.params` in file serving routes
142- Missing rate limiting on auth endpoints
143- `eval()` or `Function()` with user input
144- Event loop blocking with synchronous operations
145
146**Serverless / edge runtimes (Vercel, Lambda, Cloud Run, Workers):**
147- **In-memory state ≠ rate limit.** A module-scoped `Map` or `Set` for rate limiting, sessions, or caches is per-instance. Cold starts reset state; load spreads across instances; attackers bypass trivially.
148 - Grep for: `const rateLimitMap = new Map`, `const cache = new Map` in server-action / API-route files
149 - Fix: shared store — Vercel KV, Upstash Ratelimit, Redis, DynamoDB
150- **Unbounded in-memory collections** leak memory under traffic. Cap size and evict (LRU or FIFO).
151- **`x-forwarded-for` trust:** only trustworthy when the edge overwrites it. Behind misconfigured proxy chains it's attacker-spoofable. A fallback to a single `"unknown"` bucket throttles all anonymous traffic together; random-fallback silently disables the limit.
152
153**Spring / Java:**
154- Spring4Shell and related RCE vulnerabilities
155- Deserialization attacks (Java native serialization, Jackson polymorphic types)
156- SpEL injection in Spring Expression Language
157- Missing CSRF protection on state-changing endpoints
158- Actuator endpoints exposed without authentication
159
160**Laravel / PHP:**
161- APP_DEBUG=true in production (leaks env vars in error pages)
162- SQL injection via raw DB queries without bindings
163- Mass assignment without `$fillable` / `$guarded`
164- File upload without type validation (PHP execution via uploaded .php)
165- Insecure deserialization in queued jobs
166
167**WordPress:**
168- Outdated core, theme, or plugin versions (most common attack vector)
169- File editor enabled in wp-admin (allows code injection if admin is compromised)
170- XML-RPC enabled (brute force amplification, SSRF)
171- Default admin username, weak passwords
172- Unpatched plugin vulnerabilities (check WPScan database)
173
174### Step 4: Check for Supply Chain Risks
175
176Beyond known CVEs, look for supply chain attack indicators:
177
178**Dependency confusion / substitution:**
179- Private package names that could be claimed on public registries
180- Missing `.npmrc` or `pip.conf` scoping to private registry
181- No lockfile integrity verification
182
183**Typosquatting:**
184- Package names that are close misspellings of popular packages
185- Recently published packages with very few downloads
186- Packages that changed ownership recently
187
188**Malicious packages:**
189- Postinstall scripts that make network requests or execute code (`scripts.postinstall` in package.json)
190- Packages with obfuscated code
191- Excessive permission requests relative to functionality
192
193**Maintenance risk:**
194- Unmaintained packages (no commits in 2+ years, archived repos)
195- Single-maintainer packages for critical functionality
196- Packages with known but unpatched vulnerabilities (maintainer unresponsive)
197
198**Lockfile integrity:**
199- Lockfile committed? `git ls-files | grep -E 'package-lock\.json|yarn\.lock|pnpm-lock\.yaml|Gemfile\.lock|poetry\.lock|composer\.lock|Cargo\.lock|go\.sum'`
200- CI installs from lockfile?
201 - Check `.github/workflows/*.yml`, `.gitlab-ci.yml`, `Jenkinsfile`, `vercel.json`, `netlify.toml`, `Dockerfile`
202 - `npm install` (bad) vs `npm ci` (good); `yarn install` (bad) vs `yarn install --immutable` (good); `pip install -r` (bad) vs `pip install --require-hashes -r` (good)
203- `integrity` hashes present in the lockfile? (modern npm/pnpm yes by default)
204
205### Step 5: Check Dev Tool and CI/CD Security
206
207**GitHub Actions:**
208- `pull_request_target` trigger with checkout of PR code (code injection risk)
209- Secrets accessible in forked PR workflows
210- Unpinned action versions (`uses: actions/checkout@main` vs `@v4.1.0` or SHA pin)
211- Script injection via `${{ github.event.issue.title }}` in `run:` blocks
212
213**Docker:**
214- Running as root in container (missing `USER` directive)
215- Base image with known CVEs (check with `trivy` or `docker scout`)
216- Secrets baked into image layers (visible via `docker history`)
217- `latest` tag instead of pinned version
218
219**Terraform / IaC:**
220- Hardcoded secrets in `.tf` files
221- Unpinned provider versions
222- Missing state file encryption
223- Over-permissive IAM in provider configuration
224
225## Output Format
226
227```markdown
228# Dependency & Stack Security Audit
229## Project: [name]
230## Stack: [language, framework, key tools]
231## Date: [date]
232
233### Stack Inventory
234| Component | Version | Latest | Status |
235|-----------|---------|--------|--------|
236
237### Known Vulnerabilities (CVEs)
238| Package | Installed | Vuln | Severity | Where reachable | CVE | Fix Version |
239|---------|-----------|------|----------|-----------------|-----|-------------|
240
241Where reachable values: `runtime` / `build-only` / `dev-only`. Confirm with `npm ls --omit=dev <package>` or inspect the deployment artifact (Vercel function bundle, Docker layer). Build- and dev-only vulnerabilities should not block a release on their own; runtime-reachable ones should.
242
243### Framework-Specific Issues
244#### [SEVERITY] [Title]
245**Component:** [framework/tool name and version]
246**Issue:** [description]
247**Evidence:** [code or config snippet]
248**Remediation:** [specific fix]
249
250### Supply Chain Risks
251| Risk | Package/Component | Details | Remediation |
252|------|-------------------|---------|-------------|
253
254### Dev Tool / CI Security
255| Tool | Issue | Severity | Remediation |
256|------|-------|----------|-------------|
257
258### Prioritized Action Plan
2591. [Critical — actively exploited CVEs, RCE vulnerabilities]
2602. [High — known CVEs with public exploits, supply chain risks]
2613. [Medium — framework misconfigurations, outdated dependencies]
2624. [Low — maintenance risks, best practice improvements]
263```
264
265## Boundaries
266
267- Only audit code and configurations the user provides
268- When identifying CVEs, verify they apply to the actual installed version
269- Provide specific fix versions or remediation steps for every finding
270- Note when a vulnerability requires specific conditions to exploit (reducing effective severity)
271- Refuse to help exploit found vulnerabilities against unauthorized targets
272
273## References
274
275- OWASP Dependency-Check
276- National Vulnerability Database (NVD)
277- GitHub Advisory Database
278- Snyk Vulnerability Database
279- npm audit / pip-audit / bundler-audit documentation
280- SLSA (Supply-chain Levels for Software Artifacts) framework