← Back to Home

pip-audit 2.10.1: 37 alerts were 19 advisories

pip-auditsupply chaindependency security

A green pip-audit -r requirements.txt line in CI convinces most people that dependency security is handled. I installed pip-audit 2.10.1 on Windows 11 with CPython 3.13.14 (2.10.1 was the newest release on PyPI at the time of writing; it uploaded on 2026-06-10) and ran the same dependency file through a dozen variations: pinned to range, default service to OSV, --fix to --strict. I ran well over a dozen rounds in total.

The first result is uncomfortable. The 37 in Found 37 known vulnerabilities in 3 packages is not a vulnerability count. After deduplication it is 19. The missing 18 are not noise: each advisory is published twice under two identifier schemes, and pip-audit 2.10.1 keeps both rows.

This is a local test record, not a tool introduction. Every number below comes from output I produced myself, and the commands and files are in the text so you can reproduce them. There are no affiliate links in this post.

Where this sits in the series

Three adjacent posts already exist here, each at a different decision layer, so let me draw the boundaries first. The 09-29 post covers the CI layer: what to look at after a GitHub Actions tag gets rewritten. The xz backdoor post covers artifact provenance: what to do when a tarball and a git repository disagree. The 10-21 post covers the PEP 440 syntax layer of pinning. This one goes one level lower: the local Python dependency layer. On this machine, with this lock file, how many packages were actually audited, and how many real findings came back.

The test bench: six files, one machine

The environment is fixed: Windows 11, CPython 3.13.14, pip-audit 2.10.1 installed into an isolated directory, tmp/w46-pipa, with pip install --target so the main environment stays untouched. Every command is invoked as PYTHONPATH=tmp/w46-pipa python -m pip_audit.

I tested six files. All are short enough to recreate by hand:

Two more files were deliberately broken to capture real error text, in the Troubleshooting section.

1. Where the number 37 comes from

Start with a single package. requests==2.19.0 prints:

Found 37 known vulnerabilities in 3 packages

Three packages (requests, idna, urllib3) account for 37 rows. I fed the JSON output through a deduplication pass keyed on id, and the number changed immediately:

PackageVersionAlert rowsDistinct advisories
requests2.19.0105
idna2.742
urllib31.232312
chardet3.0.400
Total-3719

Every row appears exactly twice. That is not coincidence; it is two identifier schemes coexisting in one response.

2. Ask OSV directly: 10 records, 5 advisories

Skip pip-audit and POST straight to https://api.osv.dev/v1/query with only a name and a version:

POST /v1/query
{"package": {"name": "requests", "ecosystem": "PyPI"}, "version": "2.19.0"}

It returns 10 records, and the distinct count is also 10. OSV is not duplicating anything; it honestly reports 10 records. Look at id and aliases and the picture clarifies:

GHSA-x84v-xcm2-53pg  aliases: ["CVE-2018-18074", "PYSEC-2018-28"]
PYSEC-2018-28        aliases: ["CVE-2018-18074", "GHSA-x84v-xcm2-53pg"]
GHSA-j8r2-6x86-q33q  aliases: ["CVE-2023-32681", "PYSEC-2023-74"]
PYSEC-2023-74        aliases: ["CVE-2023-32681", "GHSA-j8r2-6x86-q33q"]

Five pairs, each pointing at its twin. This is the normal OSV shape: one GitHub Advisory and one PyPA PYSEC record describe the same problem and alias each other. The problem is what happens next.

pip-audit takes those 10 records and normalizes the primary id in pip_audit/_service/interface.py: VulnerabilityResult.create() sorts the ids and keeps the first, with PYSEC and CVE preferred. The GHSA record is rewritten to PYSEC-2018-28 too. So far this is sane; the two records now look identical.

Then it goes wrong. Deduplication in pip_audit/_audit.py runs in two passes. The first pass only picks ids starting with PYSEC and appends them without checking whether they alias each other. The second pass handles non-PYSEC records and does consult seen_aliases. The two records that entered in pass one already share the same PYSEC id and an identical alias set, but nothing stops them, so both survive.

Result: one advisory, two output rows, doubled count. Of the 23 urllib3 1.23 rows only 12 are real advisories; one, PYSEC-2026-4177, appears once because it has no PYSEC twin on the OSV side. That also explains why 37 is not a clean multiple: duplication hit most records, not all of them.

One direct piece of evidence: the two rows for the same advisory carry different description wording. The PYSEC row says "The Requests package before 2.20.0...", the GHSA row says "The Requests package through 2.19.1 before 2018-09-14...". Two renderings of one advisory.

3. The --dry-run line is the real health check

The README is explicit: pip-audit --dry-run used on its own skips the audit and only prints how many dependencies it would have audited. This is now the line I check every round:

INFO:pip_audit._audit:Dry run: would have audited 4 packages
INFO:pip_audit._audit:Dry run: would have audited 7 packages
INFO:pip_audit._audit:Dry run: would have audited 0 packages

Those three correspond to requests==2.19.0, flask>=3.0, and requests>=2.0.

The first two are fine. The third is the problem: the same unpinned style audited 7 packages for flask>=3.0 and 0 packages for requests>=2.0, with identical commands, identical exit code 0, and identical final line No known vulnerabilities found. I retested with a brand new filename; no change. Working down to pip-audit's internal temporary virtualenv showed installed_packages as an empty list, while a hand-built venv running the same pip install --dry-run --report resolved requests 2.34.2 plus four dependencies without complaint.

I read the collection logic in _dependency_source/requirement.py and the built-in venv report parser and found no explicit rule that explains the difference. So I will not present it as design intent, only as an observed behavior on 2.10.1: with range declarations, whether a package gets audited depends on the package. The only actionable conclusion is to ignore the final No known vulnerabilities found line and read the package count from --dry-run.

One more common trap lives in the same section: version drift. flask==3.0.0 reports 2 rows (1 distinct advisory, PYSEC-2026-2151, i.e. CVE-2026-27205, fixed in 3.1.3), while flask>=3.0 resolves to 3.1.3, audits 7 clean packages, and exits 0. In other words, a range declaration audits whatever the latest version will be, not the version you are running in production.

4. Three ways to audit nothing, only one is loud

CaseSymptomExit codeDoes it fire
Local path dependency (not on PyPI)one skip_reason row in JSON, not counteddecided by other packagessilent by default, fails only with --strict
Range declaration (this case)0 packages audited0silent
Typo in package name, version missingNo matching distribution found1fires

The local path case deserves its own paragraph. The JSON looks like this:

{"name": "localsample", "skip_reason": "Dependency not found on PyPI and could not be audited: localsample (0.1.0)"}

It sits in the dependencies array with no version field and no vulns. If your parser writes dep["version"], you get a KeyError; my first version crashed exactly there. It is not counted in Found N vulnerabilities and does not affect the exit code. As long as one package in the file has a finding, you still get exit 1 and it looks like "the audit ran", when in fact none of the internal packages were audited.

Adding --strict turns this into a failure, with this exact text:

ERROR:pip_audit._cli:localsample: Dependency not found on PyPI and could not be audited: localsample (0.1.0)

The README defines --strict as failing the whole audit when dependency collection fails. For projects with private packages or internal sdists, this switch is effectively mandatory.

5. --fix turns a CI failure into a success

This is the finding I least wanted and could not avoid. Copy the requests==2.19.0 file and run pip-audit --fix:

Found 37 known vulnerabilities in 3 packages and fixed 37 vulnerabilities in 3 packages

The exit code is 0. A command that should have turned the pipeline red becomes green, and it did two things: rewrote requests==2.19.0 to requests==2.33.0, and appended two dependencies that were not in the file:

requests==2.33.0
# pip-audit: subdependency explicitly fixed
idna==3.15
    # pip-audit: subdependency explicitly fixed
urllib3==2.8.0

Two details are worth remembering: the comment indentation is inconsistent (the second one has four extra spaces), and subdependencies got promoted to direct dependencies and pinned. In a flow where the lock file is tool-generated that may be fine, but if you treat requirements.txt as a hand-maintained list, the next person who edits versions will find two lines nobody remembers adding.

--fix --dry-run is the safe variant: it only prints messages like "would have upgraded requests to 2.33.0" and leaves the file alone. Use that one and keep the file-modifying step in human hands.

6. Switching the vulnerability service moves the number, not the findings

The default is not OSV. The argument parsing log prints vulnerability_service=, and the README parameter table lists the default next to PIP_AUDIT_VULNERABILITY_SERVICE. Same file with -s osv explicitly:

The deduplicated advisory sets are identical (I compared with "package name + id" as the key; both directional set differences were empty). The single extra row is one advisory that OSV copies one more time. So "the number changes when you switch services" is true, and "switching services changes what you find" is false, at least for these three packages.

7. The minimum CI wiring I would actually use

Three commands, each doing one job:

# 1. confirm how many packages will be audited (decides whether the next two mean anything)
python -m pip_audit -r requirements.txt --strict --dry-run

# 2. real audit, emit JSON and count it yourself (do not trust the final line)
python -m pip_audit -r requirements.txt --strict --progress-spinner off -f json -o audit.json

# 3. parse: dedupe on "package name + id", report distinct advisories and audited package count

For step 3 the gate should be an AND: distinct advisories equal zero, and audited package count equals what you expect (for example, the number of == lines in the lock file). Test only the first condition and you miss the "audited 0 packages" green light. Test only the exit code and you miss both, while the CI dashboard still shows 100% passing.

Two more notes: pip-audit needs network access (it builds a temporary venv so pip can resolve), so run it once first on restricted runners; and keep --fix out of the pipeline, since it converts failures into successes and edits files.

Troubleshooting: three errors I actually hit

Error 1: ResolutionImpossible

My first file declared requests==2.19.0 plus urllib3==1.24.1, hoping to "scan more at once":

ERROR:pip_audit._virtual_env:internal pip failure: ERROR: Cannot install -r tmp\audit-1109\reqs-vuln.txt (line 1) and urllib3==1.24.1 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
ERROR:pip_audit._cli:Failed to install packages: [...]

The cause is that requests 2.19.0 itself requires urllib3<1.24, which conflicts directly with the hand-pinned urllib3==1.24.1. pip-audit resolves by installing the file into a temporary environment; if that install fails there is nothing to audit. Fix: do not pin subdependencies by hand, let the resolver do it, or split the file into two runs. The good news is that this failure is loud, exit 1.

Error 2: No matching distribution found

ERROR:pip_audit._virtual_env:internal pip failure: ERROR: Could not find a version that satisfies the requirement not-a-real-package-zzz==1.0.0 (from versions: none)
ERROR: No matching distribution found for not-a-real-package-zzz==1.0.0

This one came from a deliberate fake package name. Behavior is as expected: hard fail, exit 1. But it also explains a hidden case: if a misspelled name sits deep in the tree (a bad install_requires in some dependency), the whole audit collapses instead of skipping that entry and continuing. Do not assume a network problem when you see this; check the package name and private index configuration first.

Error 3: Dependency not found on PyPI and could not be audited

ERROR:pip_audit._cli:localsample: Dependency not found on PyPI and could not be audited: localsample (0.1.0)

This appears only with --strict (without it the package is silently skipped, see section 4). Your private packages, internal SDKs, and local path dependencies all route here. Fix: when private packages live on an internal index, point at it with --index-url or --extra-index-url; for local path dependencies during development, accept the skip but add --strict in CI so the number of skipped items becomes a visible failure.

What this post does not answer

Three things, stated clearly so nobody misuses the article:

1. Why requests>=2.0 audited zero packages, I did not root-cause. The reproduction path is in section 3; at source level I only confirmed the set is empty, not the rule that produces it.

2. I only tested Windows. On Linux the temporary venv and pip install --dry-run --report may behave differently, especially with system packages.

3. I did not touch SBOM or CycloneDX output (-f cyclonedx-json). pip-audit 2.10.1 already ships cyclonedx-python-lib 11.12.0, so that path works, but it is a different decision layer and can wait.

Closing

If this post leaves one sentence, it is this: the last line pip-audit prints is not a vulnerability count, and the exit code is not audit coverage. How many distinct advisories remain after deduplication, and how many packages were actually audited, are two numbers you have to count yourself. To go further upstream, read the 10-17 xz post (how an artifact stops matching its source) and the 10-29 tarfile post (where an extracted file can land). One sits before a dependency arrives, one after it lands; the local scanning layer in this post is the space between them.

👉 Join Xiaomi MiMo Platform: Leading AI model platform with cost-effective inference

👉 Join Aliyun AI: Top AI products with exclusive coupons for business innovation

📌 This article was AI-assisted generated and human-reviewed | TechPassive — An AI-driven content testing site focused on real tool reviews

🔗 Recommended Tools

These are carefully selected tools. Using our affiliate links supports us to keep producing quality content:

As an Amazon Associate, I earn from qualifying purchases at no extra cost to you.

☁️ DigitalOcean Cloud ⚡ Vultr VPS 🤖 QoderWork CN (Refer & Earn) ☁️ Aliyun AI Products 📚 WordPress Books 🧠 AI & LLM Books 🏗️ System Design Books 🐳 Docker & K8s Books 🐧 Linux Admin Books 🐍 Python Books 🗄️ Database Books 🚀 DevOps & SRE Books 🤖 Xiaomi MiMo Platform
← Back to Home