Skip to main content

pipguard logo

pipguard

PyPI - Version codecov Documentation Python Version

Python supply chain security tool. Scan packages before installing them.

AST-based static analysis + known CVE lookup via osv.dev.

pip install pipguard
pipguard install requests          # downloads, scans, then installs

pipguard would have blocked the March 2026 litellm .pth attack before install (that release has since been pulled from PyPI — see The Problem).

Zero configuration. Zero external dependencies. Pure stdlib.

pipguard demo


The Problem

The March 2026 litellm attack (97M downloads/month) embedded Python code in a .pth file — executed automatically at interpreter startup, exfiltrating SSH keys, AWS credentials, and Kubernetes configs from a single pip install.

Classical tools (pip-audit, GuardDog) are blind to zero-day attacks. They check known signatures. pipguard asks a different question:

Should any pip install be allowed to read ~/.ssh/id_rsa?

The answer is no. And that question doesn't require a database.

How is this different from pip-audit?

They answer different questions — and pipguard is a superset:

pip-audit / Safety pipguard
Known CVE / advisory lookup ✅ (--check-vulns)
Behavioral scan of code (zero-days)
Blocks before install

pip-audit checks whether your versions have a published advisory — reactive, and blind to a brand-new attack. pipguard checks what the code actually does (reads ~/.ssh, phones home from setup.py) — catching the zero-day — and folds in the CVE check too. In a head-to-head on a credential-stealing setup.py, pip-audit reports "No known vulnerabilities found" while pipguard blocks it. Reproduce it: python benchmark/compare_pip_audit.py. See the full comparison.

Installation

Install pipguard outside your project's virtualenv — this prevents untrusted package code from tampering with the scanner itself.

# Recommended: isolated, persistent install
pipx install pipguard

# CI / one-off use (no pre-install needed)
uvx pipguard install -r requirements.txt

# Standard
pip install pipguard

Usage

# Install a single package
pipguard install requests

# Install from requirements.txt
pipguard install -r requirements.txt

# CI mode: never prompts, exits 1 on CRITICAL/HIGH
pipguard install --yes -r requirements.txt

# Allow a known-legitimate package that accesses credentials
pipguard install --allow paramiko -r requirements.txt

# Override for known false-positives (use with care)
pipguard install --force my-trusted-internal-pkg

# Show full LOW/CLEAN scan details
pipguard install --verbose requests

# Show raw pip install output
pipguard install --show-pip-output requests

By default, pipguard prints a risk summary, expands CRITICAL / HIGH / MEDIUM, collapses LOW to package-level counts, and keeps successful pip install logs quiet. Use --verbose for full scan details and --show-pip-output to restore raw pip logs.

For the full reference — risk levels, exit codes, allowlist, and CI integration — see the documentation.

CI Integration

GitHub Actions

Use the bundled composite action to gate installs in a workflow — it fails the job on CRITICAL/HIGH findings:

- uses: shenxianpeng/pipguard@v0.3.0
  with:
    requirements: requirements.txt
    check-vulns: true        # also query OSV.dev for known CVEs (optional)

Or scan explicit packages:

- uses: shenxianpeng/pipguard@v0.3.0
  with:
    packages: "requests numpy==1.26.3"

pre-commit

Add pipguard to .pre-commit-config.yaml to scan your requirements file before every commit that changes it:

repos:
  - repo: https://github.com/shenxianpeng/pipguard
    rev: v0.3.0
    hooks:
      - id: pipguard
        # scans requirements.txt by default; override for a different file:
        # args: ['-r', 'requirements/prod.txt']

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pipguard-0.4.2.tar.gz (406.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipguard-0.4.2-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file pipguard-0.4.2.tar.gz.

File metadata

  • Download URL: pipguard-0.4.2.tar.gz
  • Upload date:
  • Size: 406.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pipguard-0.4.2.tar.gz
Algorithm Hash digest
SHA256 b1226454b164641552010ffe71be5942a5cbff8d615c5a20c0b32e829aaa74ab
MD5 37546ef356d7881fa9d01b0a0697f245
BLAKE2b-256 0df3193471a4ea736787bf4b4486b110925544ee7cc9c888c024214b4f677492

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipguard-0.4.2.tar.gz:

Publisher: publish.yml on shenxianpeng/pipguard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pipguard-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: pipguard-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pipguard-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 438ce9e8b92e1d61d46bca8e4cf9d3f79e1751a6a29a8ca41a215debc2fa11f1
MD5 e96e5823ab77b627eddf1fed20ad403d
BLAKE2b-256 51772ff15350851136ec1312c27c28f57974c725e6ee4c205dab43525506f476

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipguard-0.4.2-py3-none-any.whl:

Publisher: publish.yml on shenxianpeng/pipguard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page