pip-guardian
pip-guardian is a security gate in front of pip install to reduce PyPI supply-chain risk.
Why this exists
Package ecosystems are a common attack path. pip-guardian checks package metadata and distribution contents before install, then decides ALLOW, WARN, or BLOCK.
Feature set
1) Pre-install risk policy
- Version age rules:
- block if version is very new (default
< 5h) - warn if version is recent (default
< 48h)
- block if version is very new (default
- Blocks yanked releases.
- Blocks known-compromised versions from local blocklist.
- Blocks maintainer identities from local blocklist.
2) Deep artifact scanning
- Downloads wheel/sdist artifacts from PyPI before install.
- Verifies artifact SHA256 against PyPI metadata.
- Static scan heuristics for:
- executable
.pthstartup hooks sitecustomize.py/usercustomize.py- obfuscated payload patterns (e.g., long base64 + dynamic execution)
- credential-exfiltration-like behavior
- persistence indicators (e.g., systemd artifacts)
- Kubernetes lateral-movement indicators
- executable
3) Built-in incident guard (LiteLLM March 2026)
- Blocks:
litellm==1.82.7litellm==1.82.8
- Runbook:
docs/INCIDENT_LITELLM_2026.md
4) CI-friendly JSON mode
--jsonemits one machine-readable JSON object.--yesallows non-interactive proceed onWARN.- Exit codes:
0install succeeded1blocked, warn-not-confirmed, or pip install failure2usage/argument errors
5) Logging
- Decision logs written as JSONL.
- Primary path:
~/.pip_guardian/guardian.log - Fallback path (if home not writable):
./.pip_guardian/guardian.log
Installation
Install from PyPI:
python -m pip install pip-guardian
Upgrade:
python -m pip install --upgrade pip-guardian
CLI entrypoint fix
Earlier releases had CLI entrypoint issues for some users. This is now fixed.
Upgrade and try again:
python -m pip install --upgrade pip-guardian
pip-guardian install requests
Alternative commands that now work:
pip_guardian install requests
guardian install requests
python -m guardian install requests
Install from source (development):
git clone https://github.com/AnantDhavale/pip-guardian.git
cd pip-guardian
python -m pip install .
Usage
guardian install requests
guardian install litellm==1.82.8
guardian install fastapi --index-url https://pypi.org/simple
guardian install requests --json --yes
Policy and IOC files
policies/config.yaml:- age thresholds
- deep-scan score thresholds
- executable
.pthblocking toggle
policies/blocklist.json:- package/version deny list
- maintainer deny list
Repository structure
guardian/cli.py- command entrypointguardian/policy_engine.py- risk decision logicguardian/scanner.py- deep artifact scanningguardian/pypi_checker.py- PyPI metadata collectionguardian/logger.py- local decision logging
Notes
- This reduces risk but is not a full malware sandbox.
- For production, use pinned dependencies and hash-locked installs.
Author
Anant Dhavale
anantdhavale@gmail.com
Reach out
If you are using it and finding it useful, please drop me a note. I would appreciate that ! anantdhavale@gmail.com
Check out homer-core. It's the governance middle-ware your enteprise needs, reach out for a free POC. wwww.homersemantics.com info@homersemantics.com
Release files for pip-guardian 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pip_guardian-1.0.1.tar.gz | 13.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pip_guardian-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.9 kB
Release files / pip_guardian-1.0.1.tar.gz
| Download URL | pip_guardian-1.0.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
369656434928fe459e61f5a32d1dda245e2d678bddc11f054f130fcfae7bfa4e
|
|
BLAKE2b-256 checksum How to use checksums |
47b14fc3112fff4bd7f8b218c76800808dd239377646a2998d51cbe3aa9c837d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 11, 2026.
Transparency logRelease files / pip_guardian-1.0.1-py3-none-any.whl
| Download URL | pip_guardian-1.0.1-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87697b385b9a2105b534fb6fa2591ce5c9d58f6051ec4a8304b9e8258defe36d
|
|
BLAKE2b-256 checksum How to use checksums |
89646795c4161c3e7ac6fb258bd377ee8bae233a0c809c53289474dae54e228f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 11, 2026.
Transparency log