Dependency Security Audit Guide
Modern applications depend on hundreds of third-party packages. One vulnerable transitive dependency can expose your entire application. This guide covers the tools and workflows to find, track, and fix dependency vulnerabilities at every stage of development.
Tool Comparison Overview
| Tool | Ecosystems | Free | CI/CD | Strength |
|---|---|---|---|---|
| npm audit | npm only | Yes | Yes | Zero-config, built-in |
| yarn audit | npm only | Yes | Yes | Yarn projects |
| Snyk | npm, pip, Maven, Go, etc. | Free tier | Yes | Earliest disclosures, fix PRs |
| OWASP Dep-Check | Java, .NET, Node, Python | Open source | Yes | NVD-based, HTML/XML reports |
| Dependabot | npm, pip, Maven, Go, etc. | Free on GitHub | Native GitHub | Auto-PR for updates |
| Renovate Bot | 40+ ecosystems | Open source | Yes | Most configurable |
npm audit: Basics to Advanced
# Basic audit — shows all vulnerabilities
npm audit
# JSON output for scripting
npm audit --json
# Audit only production dependencies (exclude devDeps)
npm audit --omit=dev
# Auto-fix compatible vulnerabilities
npm audit fix
# Force fix (may upgrade major versions — review changes!)
npm audit fix --force
# Fail CI if high or critical vulns found
npm audit --audit-level=high # exits 1 if high+ found
# Fix transitive dependency with npm overrides (package.json)
# "overrides": { "vulnerable-package": "^2.1.0" } Reading npm audit Output
found 3 vulnerabilities (1 moderate, 1 high, 1 critical)
# critical
lodash <=4.17.20
Severity: critical
Prototype Pollution — https://npmjs.com/advisories/1523
fix available via `npm audit fix`
node_modules/lodash
your-package > lodash
# To fix transitive dep when no direct update exists:
# In package.json:
# "overrides": { "lodash": "^4.17.21" } Snyk CLI
# Install and authenticate npm install -g snyk snyk auth # opens browser for auth # Test current project snyk test # Test with threshold (fail on high+) snyk test --severity-threshold=high # Monitor project (sends snapshot to Snyk dashboard) snyk monitor # Fix vulnerabilities (opens PR or patches) snyk fix # Test a specific package snyk test [email protected] # Ignore a vuln temporarily (creates .snyk file) snyk ignore --id=SNYK-JS-LODASH-1234567 --expiry=2026-06-01 --reason="no fix available" # Python snyk test --file=requirements.txt # Docker image scanning snyk container test node:18-alpine
OWASP Dependency-Check
# Install (requires Java) # Download from: https://github.com/jeremylong/DependencyCheck/releases # Run against Node.js project ./dependency-check.sh \ --project "MyApp" \ --scan ./node_modules \ --format HTML \ --out ./reports/ # Run against Java project ./dependency-check.sh \ --project "MyJavaApp" \ --scan ./build/libs/ \ --format "HTML,JSON,SARIF" \ --out ./reports/ # Fail build if CVSS score >= 8 ./dependency-check.sh \ --project "MyApp" \ --scan . \ --failOnCVSS 8 \ --out ./reports/
GitHub Dependabot Configuration
# .github/dependabot.yml
version: 2
updates:
# npm dependencies
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
open-pull-requests-limit: 10
groups:
# Group minor/patch updates into one PR
production-minor:
dependency-type: "production"
update-types: ["minor", "patch"]
ignore:
# Ignore major version bumps (review manually)
- dependency-name: "react"
update-types: ["version-update:semver-major"]
# GitHub Actions versions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
# Python pip
- package-ecosystem: "pip"
directory: "/backend"
schedule:
interval: "weekly" CI/CD Integration: GitHub Actions
# .github/workflows/security.yml
name: Security Audit
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
schedule:
- cron: '0 6 * * 1' # Weekly Monday 6am
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
# npm audit — fail on high+ severity
- name: npm audit
run: npm audit --audit-level=high --omit=dev
# Snyk (requires SNYK_TOKEN secret)
- name: Snyk security scan
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high
# Dependency Review (checks PRs for new vulns)
- name: Dependency review
uses: actions/dependency-review-action@v4
with:
fail-on-severity: high CVE Severity Levels Reference
| CVSS Score | Severity | Response Time | Example Impact |
|---|---|---|---|
| 9.0 – 10.0 | Critical | Immediate / <24h | Unauthenticated RCE (Log4Shell) |
| 7.0 – 8.9 | High | <7 days | Auth bypass, privilege escalation |
| 4.0 – 6.9 | Medium | Next release cycle | XSS with specific conditions |
| 0.1 – 3.9 | Low | Scheduled maintenance | Minor info disclosure |
Frequently Asked Questions
What is the difference between npm audit and Snyk?▼
npm audit is a free, built-in tool that checks your dependencies against the npm Advisory Database (which sources from NVD and GitHub Advisory Database). It's fast and requires no account. Snyk goes deeper: it has its own vulnerability database (often earlier disclosures), tracks vulnerabilities in container images and IaC configs, provides fix PRs, integrates with Jira, and has a dashboard for teams. npm audit is a good baseline; Snyk is better for teams and enterprise use cases. Both check direct and transitive dependencies.
How do I fix a vulnerability in a transitive dependency?▼
Transitive (indirect) dependencies can't be directly pinned in package.json. Options: (1) npm overrides / yarn resolutions — force a specific version of the transitive dep. (2) Update the direct dependency that includes the vulnerable transitive one. (3) If no fix is available, add a note in your audit config to accept the risk temporarily. Use 'npm audit fix --force' carefully — it may introduce breaking changes. Check if the vulnerability is actually reachable in your code path before treating it as critical.
What do CVE severity levels mean?▼
CVEs are scored using CVSS (Common Vulnerability Scoring System) 0-10: Critical (9.0-10.0) — exploitable without authentication, often RCE. High (7.0-8.9) — significant impact, usually needs some access. Medium (4.0-6.9) — limited impact or needs specific conditions. Low (0.1-3.9) — minimal impact or hard to exploit. Note that CVSS scores reflect severity in general, not necessarily in your specific context. A critical vulnerability in a dev-only dependency exposed to no external input may carry very low actual risk.
How do I integrate dependency auditing into CI/CD?▼
For npm: add 'npm audit --audit-level=high' to your CI pipeline — it exits non-zero if high/critical vulns are found, failing the build. For GitHub Actions, use the actions/dependency-review-action which checks PRs for new vulnerable dependencies. Snyk CI: 'snyk test --severity-threshold=high'. OWASP Dependency-Check can produce SARIF/HTML/XML reports as CI artifacts. Set thresholds appropriate to your risk tolerance — blocking on every medium vuln leads to alert fatigue.
What is a Software Bill of Materials (SBOM) and do I need one?▼
An SBOM is a formal, machine-readable inventory of all components in your software — direct deps, transitive deps, version numbers, licenses, and known vulnerabilities. Government contracts (US Executive Order 14028), financial sector, and healthcare increasingly require SBOMs. Generate with: 'npm install -g @cyclonedx/cyclonedx-npm && cyclonedx-npm' or Syft. SBOMs enable rapid vulnerability response — when a new CVE drops (like Log4Shell), you can immediately know which products are affected.
How does GitHub Dependabot work and how is it different from Renovate Bot?▼
Dependabot is GitHub's native dependency update bot. It opens PRs to update vulnerable packages (security updates) and can also open PRs for general version updates. It's zero-config for security updates. Renovate Bot (by Mend) is more configurable: it groups updates, allows custom scheduling, supports monorepos better, handles more package managers, and has more merge strategies. Both are free for public repos. Renovate is preferred by teams needing fine-grained control; Dependabot is a solid no-config baseline.
Related Products
on GumroadPremium Workflow Pack
Production-grade workflows, architecture guides, and deployment scripts for teams that ship. 10 advanced CI/CD workflows (blue-green, canary, E2E, security), 5 architecture deep-dives, code review checklist, PR process guide, and 5 battle-tested Bash deployment scripts.
Buy on Gumroad →GitHub Actions CI/CD Templates Pack
12 production-ready GitHub Actions workflow templates covering Node.js, Python, Docker, multi-environment deployments, security scanning, and auto-changelog. Copy, paste, ship.
Buy on Gumroad →Developer Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →You Might Also Need
HTTP Security Headers Generator
Generate HTTP security headers configuration for nginx and Apache. Configure HSTS, CSP, X-Frame-Options, Referrer-Policy, and more with toggle switches. Copy ready-to-use configs.
Open free tool →
HTTP Security Headers Checker
Paste HTTP response headers and get a checklist of security headers present or missing. Checks CSP, HSTS, X-Frame-Options, and more.
Open free tool →
CI/CD Pipeline Generator
Generate complete CI/CD pipeline YAML for GitHub Actions, GitLab CI, or CircleCI. Supports Node.js, Python, Docker, and Go projects with test, build, and deploy stages.
Open free tool →
More Free Tools
Related Articles
Turborepo vs Nx vs Lerna: Monorepo Tools Guide 2026
Turborepo vs Nx vs Lerna: a complete 2026 comparison of the top monorepo tools. Compare remote caching, task pipelines, DX, and CI performance to choose the right tool for your team.
Docker Compose 開發環境架設:前端、後端、資料庫一鍵啟動
用 Docker Compose 建立完整的本地開發環境,包含 React 前端、Node.js 後端、PostgreSQL 資料庫,一個指令啟動所有服務,告別「在我電腦上可以跑」的問題。
GitHub Actions 入門必讀:從 0 到自動化部署
完整的 GitHub Actions 新手教學,從基本概念、workflow 語法到實戰 CI/CD 自動部署。附完整 YAML 範例,30 分鐘學會持續整合。
Authentication Security Tools 2026: Modern Auth Patterns, MFA, Passwordless, and OAuth2
Complete guide to authentication security tools in 2026. Covers Auth0, Clerk, NextAuth.js v5, JWT security, Passkeys/WebAuthn, TOTP authenticator apps, OAuth2/OIDC, session management, and building secure auth systems with Node.js and Python.
DevOps Automation Tools in 2026: Orchestrating the Software Delivery Pipeline
Master DevOps automation with this guide to the tools that orchestrate modern software delivery. Covers CI/CD pipelines, infrastructure provisioning, configuration management, testing automation, and the emerging AI-assisted automation patterns that define 2026.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →