Audit Dependency Vulnerabilities
Systematically scan, triage, and remediate known vulnerabilities in third-party dependencies to reduce supply chain risk.
Why This Is Best Practice
Adopted by: GitHub (Dependabot), Snyk (used by Google, Salesforce, Adobe), OWASP top 10 mandates
Impact: OWASP A06:2021 moved Vulnerable Components from #9 to #6; the Log4Shell vulnerability (CVE-2021-44228) affected 93% of enterprise cloud environments and cost organizations an average of $4.6M to remediate (IBM 2022).
Why best: Third-party code is the majority of most applications. Vulnerabilities in transitive dependencies are as exploitable as direct ones — Log4Shell was a transitive dependency in most affected systems. Automated scanning must be continuous, not a one-time audit.
Steps
- Generate a Software Bill of Materials (SBOM) — Produce a dependency manifest:
npm list --all, pip freeze, mvn dependency:tree, or use syft for container images.
- Run automated scanning — Execute
npm audit, pip-audit, snyk test, or trivy against the SBOM. Integrate into CI so every PR is scanned.
- Triage by CVSS score and exploitability — Critical (CVSS 9+): fix immediately. High (7-8.9): fix within 7 days. Medium: next sprint. Low: backlog. Check if the vulnerable code path is actually reachable in your usage.
- Check transitive dependencies — Direct deps rarely expose the full risk; audit the full dependency tree including transitive deps.
- Apply fixes — Update to patched versions; if no patch exists, assess: remove the dependency, replace it, or apply a virtual patch (WAF rule, input validation).
- Enable automated PRs — Configure Dependabot or Renovate to auto-open PRs for patch updates; auto-merge patch-level updates that pass CI.
- Monitor continuously — Subscribe to GitHub Advisory Database or Snyk alerts for your dependency set; new CVEs emerge after your last scan.
Rules
- Never dismiss a critical CVE without documented justification (the vulnerable function is not called, etc.).
- Treat
npm audit --production and --all separately — dev dependency vulnerabilities are lower risk but not zero risk.
- Pin dependency versions in production; use lockfiles (package-lock.json, Pipfile.lock); verify checksums.
- Audit container base images separately — OS-level vulnerabilities are not caught by language package scanners.
Examples
# Quick audit
npm audit --audit-level=high
snyk test --severity-threshold=high
# SBOM generation
syft . -o spdx-json > sbom.json
grype sbom:sbom.json
Triage note: lodash@4.17.20 — CVE-2021-23337 (prototype pollution, CVSS 7.2). Assessment: lodash.template not used in this codebase → Medium priority; update in next sprint.
Common Mistakes
- Auditing only direct dependencies — most exploited CVEs are in transitive deps.
- Ignoring "low" severity — chained with other vulnerabilities, low-severity issues enable escalation.
- No CI integration — weekly manual audits miss vulnerabilities introduced between scans.
1---2name: audit-dependency-vulnerabilities3description: Use when auditing third-party dependencies for known vulnerabilities, license issues, or supply chain risks4source: OWASP A06:2021 – Vulnerable and Outdated Components; NIST NVD (nvd.nist.gov); Snyk (snyk.io); GitHub Advisory Database5tags: [security, dependencies, vulnerabilities, owasp, supply-chain, cve, snyk]6verified: true7metadata:8 source: https://skillmd.com/skills/jeffreytse/audit-dependency-vulnerabilities9---1011# Audit Dependency Vulnerabilities1213Systematically scan, triage, and remediate known vulnerabilities in third-party dependencies to reduce supply chain risk.1415## Why This Is Best Practice1617**Adopted by:** GitHub (Dependabot), Snyk (used by Google, Salesforce, Adobe), OWASP top 10 mandates18**Impact:** OWASP A06:2021 moved Vulnerable Components from #9 to #6; the Log4Shell vulnerability (CVE-2021-44228) affected 93% of enterprise cloud environments and cost organizations an average of $4.6M to remediate (IBM 2022).1920**Why best:** Third-party code is the majority of most applications. Vulnerabilities in transitive dependencies are as exploitable as direct ones — Log4Shell was a transitive dependency in most affected systems. Automated scanning must be continuous, not a one-time audit.2122## Steps23241. **Generate a Software Bill of Materials (SBOM)** — Produce a dependency manifest: `npm list --all`, `pip freeze`, `mvn dependency:tree`, or use `syft` for container images.252. **Run automated scanning** — Execute `npm audit`, `pip-audit`, `snyk test`, or `trivy` against the SBOM. Integrate into CI so every PR is scanned.263. **Triage by CVSS score and exploitability** — Critical (CVSS 9+): fix immediately. High (7-8.9): fix within 7 days. Medium: next sprint. Low: backlog. Check if the vulnerable code path is actually reachable in your usage.274. **Check transitive dependencies** — Direct deps rarely expose the full risk; audit the full dependency tree including transitive deps.285. **Apply fixes** — Update to patched versions; if no patch exists, assess: remove the dependency, replace it, or apply a virtual patch (WAF rule, input validation).296. **Enable automated PRs** — Configure Dependabot or Renovate to auto-open PRs for patch updates; auto-merge patch-level updates that pass CI.307. **Monitor continuously** — Subscribe to GitHub Advisory Database or Snyk alerts for your dependency set; new CVEs emerge after your last scan.3132## Rules3334- Never dismiss a critical CVE without documented justification (the vulnerable function is not called, etc.).35- Treat `npm audit --production` and `--all` separately — dev dependency vulnerabilities are lower risk but not zero risk.36- Pin dependency versions in production; use lockfiles (package-lock.json, Pipfile.lock); verify checksums.37- Audit container base images separately — OS-level vulnerabilities are not caught by language package scanners.3839## Examples4041```bash42# Quick audit43npm audit --audit-level=high44snyk test --severity-threshold=high4546# SBOM generation47syft . -o spdx-json > sbom.json48grype sbom:sbom.json49```5051Triage note: `lodash@4.17.20` — CVE-2021-23337 (prototype pollution, CVSS 7.2). Assessment: `lodash.template` not used in this codebase → Medium priority; update in next sprint.5253## Common Mistakes5455- **Auditing only direct dependencies** — most exploited CVEs are in transitive deps.56- **Ignoring "low" severity** — chained with other vulnerabilities, low-severity issues enable escalation.57- **No CI integration** — weekly manual audits miss vulnerabilities introduced between scans.