Square CloudSquare Cloud

npm audit, pip-audit, Dependabot or OSV: how to find vulnerable dependencies

Run npm audit or pip-audit in CI, turn on Dependabot alerts and use OSV-Scanner when the project mixes languages. All of them compare the versions in your lockfile with public vulnerability databases, such as the GitHub Advisory Database and OSV.dev.

Updated 7 min read

Learning objectives

After reading this article you will be able to:

  • Understand what npm audit, pip-audit, Dependabot and OSV-Scanner read and where their advisories come from
  • Run each tool on your machine and in CI, with real commands
  • Handle transitive dependencies and false positives, and pick the tool per scenario
On this page

Most of the code running in your app was written by other people. An npm install express brings in dozens of packages; a five-line requirements.txt can resolve to thirty. When a vulnerability is published for one of those versions, it applies to you, even if you never opened the affected file.

Dependency scanners handle the tedious part: they check, package by package, whether the version you use shows up in a public vulnerability database. This guide covers what npm audit, pip-audit, Dependabot and OSV-Scanner read, where their data comes from, where each one runs and how to choose.

What does a dependency scanner do, and what does it not do?#

Every scanner follows the same script. It reads the project's dependency list, builds ecosystem, name and version tuples, queries an advisory database and returns the matches: the advisory id (GHSA, PYSEC, CVE), the severity and the version that fixes it.

The quality of the list sets the quality of the result:

  • Manifest (package.json, pyproject.toml) declares ranges, such as ^4.17.0. The scanner cannot tell which version is actually installed.
  • Lockfile (package-lock.json, pnpm-lock.yaml, poetry.lock, uv.lock) records the exact version of every package, including the dependencies of your dependencies. It is the source that makes results precise.

The data comes from a few places. The GitHub Advisory Database gathers advisories reviewed by GitHub, entries from the NVD and malware alerts, published in the OSV format. The PyPI Advisory Database, run by the PyPA, covers Python packages. OSV.dev, from Google, aggregates both and several others, such as the Go and Rust databases.

The limit is clear: a scanner only recognizes vulnerabilities already published for third-party packages. It will not find SQL injection in your code or an open port on your server. To see where it ends and a penetration test starts, read pentest vs vulnerability scan.

How do you use npm audit (and pnpm audit)?#

npm audit ships with npm. It sends the name and versions of each package to the configured registry's bulk advisory endpoint, and on the public registry the answers come from the GitHub Advisory Database. By default it requires a package-lock.json:

bash
npm audit                         # full report
npm audit --omit=dev              # skip devDependencies
npm audit --audit-level=high      # exit with an error only from "high" up
npm audit fix                     # update within the ranges in package.json
npm audit fix --force             # accept major versions: run your tests after

Two details prevent surprises. --audit-level sets the severity from which the command exits with an error, which is what matters in CI. And --omit=dev drops build and test tools from the report, since they never reach production.

In pnpm, the equivalent is pnpm audit, which queries the same endpoint. --prod limits it to dependencies and optionalDependencies, and --fix writes overrides to pnpm-workspace.yaml to force fixed versions.

How do you use pip-audit?#

pip-audit is maintained by the PyPA. By default it queries the PyPI Advisory Database through PyPI's JSON API; with -s osv, it uses OSV.dev. Without arguments, it audits the active Python environment, so activate the project's virtualenv first:

bash
pip install pip-audit
pip-audit                          # the current environment
pip-audit -r requirements.txt      # a requirements file
pip-audit .                        # a project with pyproject.toml
pip-audit --locked .               # the project's pylock.*.toml lockfiles
pip-audit --fix --dry-run          # show the upgrades that would fix it
pip-audit --ignore-vuln PYSEC-2021-66  # ignore one specific id

The exit code is 1 when a vulnerability is found, and the project states that this exit code cannot be suppressed. The docs list two limits. First, pip-audit -r resolves the file the way pip install -r would, so only audit requirements you trust; a fully pinned file skips that resolution with --no-deps (or --require-hashes, if it has hashes). Second, do not expect it to flag flaws in a native library that a Python package uses.

How does Dependabot work?#

Dependabot is part of GitHub and runs with nothing to install. It has three features:

  1. Alerts. The dependency graph parses the repository's manifests and lockfiles, and GitHub raises an alert when a new advisory affects one of your versions or when a push changes your dependencies. Only GitHub-reviewed advisories trigger alerts; malware alerts have their own setting.
  2. Security updates. For each alert, it tries to open a pull request with the lowest version that fixes it. For a transitive dependency it does not always manage: in several ecosystems, if the fix requires updating the parent package, no PR is opened.
  3. Version updates. Periodic pull requests that keep everything current, vulnerable or not, configured in a file:
yaml
# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "weekly"
  - package-ecosystem: "pip"
    directory: "/"
    schedule:
      interval: "weekly"

The strength is continuous watching: an advisory published today becomes an alert without any commit from you. The limit is scope, which is whatever is in the repository: anything installed outside the lockfile does not show up.

When should you use OSV-Scanner or another scanner?#

OSV-Scanner is the command-line client for OSV.dev, maintained by Google. It understands lockfiles from many ecosystems in one command (package-lock.json, pnpm-lock.yaml, yarn.lock, requirements.txt, poetry.lock, uv.lock, go.mod, Cargo.lock, Gemfile.lock, composer.lock and others), which makes it the natural pick for monorepos with several languages:

bash
osv-scanner scan -r ./                 # scan the whole repository
osv-scanner scan -L package-lock.json  # one specific lockfile
osv-scanner scan image my-api:latest   # packages inside a container image
osv-scanner fix -M package.json -L package-lock.json  # suggest fixes

It installs as a binary or through brew, winget, scoop or go install, and it has an official GitHub Action. Its docs warn that fix is risky on projects you do not trust. To silence a finding, an osv-scanner.toml in the lockfile's folder takes exceptions with a reason and an expiry date:

toml
[[IgnoredVulns]]
id = "GHSA-xxxx-xxxx-xxxx"
effectiveUntil = 2027-03-01  # after this date, the alert comes back
reason = "Only affects server mode, which we do not use"

Some ecosystems have their own scanner worth knowing. govulncheck, from the Go team, analyzes your code and only reports vulnerabilities in functions your program actually calls, directly or indirectly.

How do you deal with transitive dependencies and false positives?#

Most findings sit in transitive dependencies. The cleanest path is to update the direct package that pulls them in. To find out which one, run npm explain qs with dependencies installed, or check GitHub's dependency graph. When the parent package has not shipped a fixed version yet, force the safe version with overrides in package.json and test:

json
{
  "overrides": {
    "qs": "^6.14.0"
  }
}

In Python, pin the fixed version in your requirements or constraints file and run pip-audit again.

A false positive, in practice, is almost always a true alert that does not affect you: the vulnerable function is never called, the flaw needs a configuration you do not use, or the package only runs in development. Before ignoring it, check three things in the advisory: the affected versions, the exploit conditions and whether the package ships to production. If you do ignore it, record the reason and a review date, as in the osv-scanner.toml above. An exception with no deadline turns into oblivion.

Also remember that advisory databases lag: GitHub warns that new vulnerabilities may take time to appear. Running the scanner again, on a schedule, is part of the job.

Which tool should you use for each scenario?#

Scenario Tool
Node.js project, on your machine and in CI npm audit --omit=dev --audit-level=high (or pnpm audit --prod)
Python project pip-audit -r requirements.txt or pip-audit .
GitHub repository, continuous warnings Dependabot alerts and security updates
Multi-language monorepo or container image OSV-Scanner
Go project govulncheck, which filters by what the code calls

A combination that covers most projects well: your package manager's auditor in CI, to stop problems before the merge, and Dependabot or a scheduled run, to catch advisories published later. In GitHub Actions, a job that runs on pull requests and every Monday looks like this:

yaml
# .github/workflows/audit.yml
name: audit
on:
  pull_request:
  schedule:
    - cron: "0 6 * * 1"
jobs:
  node:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: lts/*
      - run: npm audit --omit=dev --audit-level=high
  python:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-python@v7
        with:
          python-version: "3.x"
      - run: pip install pip-audit
      - run: pip-audit -r requirements.txt

If CI is new to you, start with what CI/CD is and deploying with GitHub Actions. The scanner is one item among many on the deploy security checklist, and a malicious npm package found in production calls for the hacked app playbook.

How to do this on Square Cloud#

On Square Cloud, Cubic, the AI agent in the dashboard, runs a read-only check-up of your app on every plan: type /checkup in the chat (up to 3 every 10 minutes). Known vulnerabilities come from OSV.dev, which gathers the GitHub Advisory Database, PyPA, the Go vulnerability database, RustSec and others, for npm, PyPI, Composer, Go modules, crates.io, RubyGems and Hex. Packages are read from the root lockfiles and from what the app installed, so transitive dependencies are included.

Each finding comes with its severity, the advisory and CVE ids and the version that fixes it, and a known malicious package shows up as critical. The check-up also flags credentials written in the code (file and line, never the value), the RAM peak of the last 24 hours against the limit, and automatic restart turned off. Only each package's ecosystem, name and version are sent to OSV.dev, and anything that could not be read is listed as "not checked", never as "all clear".

It is a dependency and configuration check, not a penetration test or an audit, and it does not replace the auditor in CI: CI stops the vulnerability before the merge, and the check-up also looks at what the app installed on the server. See the details on vulnerability scanning.

Infrastructure

L3/L4/L7 DDoS mitigation and a WAF on every plan

Vulnerability scanning

FAQs

Can npm audit fix break my project?

Without flags, it only installs versions inside the ranges in package.json. With --force, it may jump to major versions, which often bring breaking changes. Run your tests after any automatic fix.

Do I need more than one tool?

Two are usually enough: an auditor in CI that fails the build when something serious shows up, and a continuous service such as Dependabot that warns you when a new advisory hits a version you already use.

Does a dependency scanner replace a penetration test?

No. It only compares package names and versions with known vulnerabilities. It does not test your logic, your configuration or flaws in your own code.

Why do I get a vulnerability in a package I never installed?

Because it is almost always a transitive dependency, pulled in by another package of yours. With dependencies installed, npm explain <package> shows the path, and GitHub's dependency graph does the same on the web.

Next articleWhere to store secrets: .env, platform variables or a vaultKeep secrets in a .env file only for local work, in platform variables in production, in CI secrets for the pipeline and in a vault once teams and rotation grow.

More in Security

See all 24 articles