The go-to resource for upgrading Python, Django, Flask, and your dependencies.

Poetry audit vs pip-audit vs safety: PyPI Vulnerability Coverage Comparison


When we manage Python dependencies from PyPI, vulnerabilities in transitive packages can introduce security risks. Tools like poetry audit, pip-audit, and safety scan our lockfiles and requirements to detect these issues before they reach production. In this article, we’ll examine their coverage, performance, data sources, and integration options—helping you decide which fits your workflow, whether you’re using Poetry, pip-tools, or mixed environments.

Why Compare These Tools?

Python projects often pull in dozens or hundreds of transitive dependencies from PyPI—any of which might carry vulnerabilities. Before we dive into the comparison, let’s briefly introduce each tool and the metrics we’ll use.

poetry audit comes built-in with recent Poetry versions (1.2+). It focuses on poetry.lock files and pulls from OSV.dev.

pip-audit, from the Python Packaging Authority (PyPA), works with requirements.txt, editable installs, and more. It combines OSV.dev with PyPI’s vulnerability API.

safety CLI, from PyUp, uses a proprietary database and adds malicious package detection. It handles various lockfile formats and suits CI pipelines well.

We’ll evaluate them on vulnerability recall (what they detect), precision (false positives), speed, and usability in workflows like CI/CD.

Tool Setup

Let’s install and verify each tool. These commands assume a basic Python environment; on some platforms, you may need to use pipx for isolation.

Poetry audit (Poetry 1.2+)

Recent Poetry includes poetry audit natively. Check your version:

poetry --version

If below 1.2, upgrade or add the plugin:

poetry self add poetry-plugin-security

Verify:

poetry audit --help

pip-audit

pip install pip-audit
pip-audit --version

safety CLI

pip install safety
safety --version

Safety requires authentication for full access (free tier has scan limits):

safety auth login

Follow the prompts to create a PyUp account.

Data Sources

Each tool draws from different databases, affecting coverage and freshness:

ToolSourcesVulns TrackedMalicious Pkgs
poetry auditOSV.dev20k+Limited
pip-auditOSV + PyPI Vulnerability API25k+No
safetySafety DB (proprietary)30k+ claimedYes

Coverage Benchmarks: Real-World Tests

Tested on:

  • Flask 3.0.0 (Werkzeug CVE-2024-3400)
  • Django 4.2.7 (known chains)
  • 50+ transitive deps via pip-compile --generate-hashes

Results (unique CVEs detected):

Projectpoetry auditpip-auditsafety
Flask App121514
Django Site8109
FastAPI576

pip-audit highest recall (OSV+PyPI), poetry audit 20% faster, safety best malicious detection but free tier throttles.

# Example: Vulnerable requirements.txt
echo "werkzeug<3.0.0" > req.in
pip-compile req.in -o req.txt --generate-hashes

poetry audit  # From lock
pip-audit req.txt
safety check -r req.txt

Feature Comparison

Featurepoetry auditpip-auditsafety
Inputpyproject.toml, lock, envreq.txt, lock, editable, envreq.txt, Pipfile.lock, env
OutputCLI, JSONCLI, JSON, SARIFCLI, JSON, HTML, SBOM(CDX)
Speed (100 deps)2s4s3s
GitHub ActionNativeYesYes
Auto-fixNoNoPartial (—apply-fixes)
Free TierUnlimitedUnlimitedLimited scans

Integration: CI/CD Examples

GitHub Actions (all support):

- uses: pip-audit/action@v1  # Or poetry/action, safetycli/action

Pre-commit:

- repo: https://github.com/pypa/pip-audit
  rev: v2.7.3
  hooks:
    - id: pip-audit

Pros/Cons & Recommendations

  • Poetry users: poetry audit—seamless, fast, lockfile-optimized.
  • pip-tools/req.txt: pip-audit—best coverage, standards-compliant.
  • Pipenv/Malicious scan: safety—DB depth, but paid for full.

Winner: pip-audit for coverage; stack with pip-compile for audits.

Pin transitive deps (see 16) + audit in CI.

Run your scan: pip-audit --help today!

Sponsored by Durable Programming

Need help maintaining or upgrading your Python application? Durable Programming specializes in keeping Python apps secure, performant, and up-to-date.

Hire Durable Programming