At a glance
What you need
- A project with a package manager (npm, pip, Composer, Maven, Go modules or similar)
- A continuous integration service (GitHub Actions, GitLab CI or similar), optional but recommended
Your application is mostly other people's code. When a flaw is found in one of the libraries you include, or in one of their own dependencies, it is a flaw in your application until you update. The good news: finding and fixing these known flaws is one of the most automatable jobs in security.
📋
List
A committed lock file says exactly what you ship.
🔎
Scan
One free command checks it against public flaw databases.
🩹
Fix what matters first
Flaws attackers already use go to the top of the list.
Step 1: Know exactly what you ship
Your package manager already keeps the list. Commit the lock file, so developers, the build server and production all install the same versions:
Build from it (npm ci, composer install, pinned versions with pip) instead of resolving versions afresh each time.
Step 2: Run your ecosystem's audit command
Each ecosystem has a free command that compares your lock file with public vulnerability databases. Run yours now, once, and read the result: each finding names the package, the vulnerable versions, the fixed version and a severity.
# JavaScript
npm audit
# PHP
composer audit
# Python
pip-audit
# Go (also tells you whether your code calls the vulnerable function)
govulncheck ./...
# Rust and Ruby
cargo audit
bundle exec bundler-audit
# Many languages at once
osv-scanner scan source -r .
Tip: one tool for every language
OSV-Scanner reads most lock files and checks them against the open OSV.dev database in one pass: handy for projects that mix a JavaScript front end with a PHP, Python or Go back end.
Step 3: Make it automatic
A check you have to remember will be forgotten.
- Audit on every pull request. Add the audit command to your continuous integration, and fail the build on high and critical findings.
- Audit every day. New flaws are published daily, even when your code does not change: schedule a nightly run.
- Let a robot open the update. Turn on Dependabot (GitHub), Renovate (GitHub or GitLab) or GitLab's dependency scanning. They open a ready-made pull request when a fix is released; your tests tell you whether it is safe to merge.
Step 4: Decide what to fix first
An audit can list dozens of findings. They are not all urgent.
⚠ Fix today: flaws attackers already use
If the CVE is in the Known Exploited Vulnerabilities catalog of the US Cybersecurity and Infrastructure Security Agency, attackers are using it now. The Canadian Centre for Cyber Security also publishes alerts for flaws affecting Canadian organizations, and our critical CVE list tracks the worst of them.
Fix this week
- Critical and high severity
- In code that handles input from the internet: forms, uploads, parsing, sign-in
- A high EPSS score (likely to be exploited soon)
Fix in your regular cycle
- Medium and low severity
- Development-only tools that never reach production
- Code paths your application never calls
Step 5: Update safely
- Prefer the smallest update that contains the fix: a patch release rather than a new major version.
- If the fix is only in a dependency of a dependency, force a safe version until the parent catches up:
overridesin npm,resolutionsin Yarn, constraints in Composer and pip. - Run your tests, deploy, and confirm the audit comes back clean.
- No fix yet? Read the advisory: there is often a setting or workaround, and you can decide whether to keep the feature that needs the library.
Step 6: Keep the list short
Every dependency is code you trust with your users' data. Once or twice a year, remove the ones you no longer use, and think twice before adding a large library for a small job.
Fewer dependencies mean fewer alerts, and fewer ways in.
Going further: a software bill of materials
A software bill of materials (SBOM) is a standard list of everything your application contains, in CycloneDX or SPDX format. Larger customers and public-sector buyers increasingly ask for one. Syft, the CycloneDX generators or GitHub's dependency graph export produce it from your lock files in seconds.
Keep learning
Next: the habits that prevent the most common web flaws, and how to keep secrets out of Git.
Sources
- OSV.dev: open source vulnerability database
- OSV-Scanner
- CISA Known Exploited Vulnerabilities catalog
- FIRST: Exploit Prediction Scoring System (EPSS)
- GitHub Docs: Dependabot
- OWASP Top 10
- Canadian Centre for Cyber Security
This guide was drafted with the help of AI from the public sources listed above, then checked and edited by the newsroom. See how we use AI.
