A typical application contains far more third-party code than your own. A flaw or a malicious change in a dependency becomes a flaw in your product, which is why this area is called supply chain security.
Know what you run
A lockfile records the exact version of every direct and indirect dependency, so builds are reproducible and you can answer "are we affected?" quickly. Commit it. Keep the list of direct dependencies short: every package you add is code you trust.
Scan for known vulnerabilities
Public databases list vulnerabilities by identifier, for example CVE numbers. Scanners compare your lockfile with them.
# Examples; use the tool that matches your ecosystem.
bundle audit check --update
npm audit
pip-auditRun the scan in CI so a vulnerable version fails the build, and also on a schedule, because new vulnerabilities are published for code that has not changed.
Update steadily
Small frequent updates are easier than a huge jump after two years. Use automated pull requests from a dependency bot, read the changelog for breaking changes, and let your test suite do the checking. Prioritise fixes by exposure: is the vulnerable function reachable in your application?
Reduce the risk of a bad package
- Prefer well-known, actively maintained packages with several maintainers.
- Beware of typosquatting, a malicious package with a name close to a popular one.
- Pin versions and review changes to lockfiles in pull requests.
- Disable or review install scripts, which run code on your machine at install time.
- Use a private registry or a proxy for critical environments.
Build integrity
Build from clean, pinned environments, verify signatures or checksums where they exist and keep a software bill of materials (SBOM), a machine-readable list of everything inside an artefact. When a new vulnerability is announced, the SBOM tells you in minutes where it lives.
Takeaway
Commit lockfiles, scan automatically, update in small steps and add dependencies deliberately. Treat every package as a decision, not a convenience.
Comments