How to Find and Control Critical Dependencies
In this article
Identify and manage critical dependencies in your software stack by scanning for direct and transitive packages, assessing their risks, and enforcing policies to maintain security, stability, and compliance. This process prevents outages, security breaches, and technical debt caused by unmonitored third-party code.
What You'll Need
- A package manager compatible with your language (e.g., npm, pip, bundler, cargo)
- Access to your project’s source code and dependency manifest files (e.g., package.json, requirements.txt)
- Dependency scanning tools (e.g., npm audit, pip-audit, Snyk, Dependabot, OWASP Dependency-Check)
- Version control system (e.g., Git) to track and manage changes
- CI/CD pipeline access (optional but recommended for automated enforcement)
- Security policy document or team guidelines on acceptable risk levels
Step-by-Step
- Generate a full dependency tree using your package manager. Run commands like
npm ls,pipdeptree, orbundle list --verboseto list all direct and nested dependencies. This reveals hidden or transitive packages that may not be explicitly declared in your manifest. - Export a software bill of materials (SBOM). Use tools like
syft,cyclonedx-cli, or built-in CI integrations to create a machine-readable list of all components. This is essential for auditing and compliance. - Scan dependencies for known vulnerabilities. Use
npm audit,pip-audit, or third-party tools like Snyk or Dependabot to check against public vulnerability databases such as the National Vulnerability Database (NVD). - Identify critical dependencies based on usage and risk. Flag packages that are: actively exploited, unmaintained, have high severity CVEs, or are deeply nested in core functionality. Prioritize those used in production, authentication, data handling, or network-facing components.
- Review license compliance. Check each critical dependency’s license type (e.g., GPL, MIT, Apache) using tools like
license-checkeror FOSSA. Ensure licenses align with your organization’s policies to avoid legal issues. - Freeze or pin critical dependencies to specific versions. Update your manifest files to lock versions (e.g.,
"express": "4.18.2"instead of"^4.18.0") to prevent unexpected updates that could introduce breaking changes or new vulnerabilities. - Set up automated monitoring. Integrate Dependabot, Renovate, or Snyk into your repository to receive alerts when new vulnerabilities are disclosed or updates are available. Configure alerts to notify maintainers immediately.
- Enforce dependency policies in CI/CD. Add pre-commit or pre-merge checks that block builds if critical dependencies have unpatched vulnerabilities or non-compliant licenses. Use scripts or tools that fail the pipeline when policy thresholds are exceeded.
- Document decisions for exceptions. If a risky dependency must remain, record the justification, mitigation steps (e.g., isolation, monitoring), and review date. Share this with security and engineering teams.
- Regularly rotate and update dependencies. Schedule quarterly reviews to upgrade or replace critical dependencies. Replace abandoned packages with actively maintained alternatives when possible.