A defensive pip wrapper with supply-chain preflight checks.
Project description
Not Finished Yet. Contribution Welcome. Site at https://spip.lamentxu.top/
secured_pip
English | 简体中文
An open-source, free, powerful, light-weight guard for your pip to avoid supply-chain attacks.
By using this, you can avoid being screwed by the poisoned LiteLLM, etc. just because you type pip install
Although secured_pip is designed for low learning budget, we still recommend you to read our docs before you try this product in your production environment.
What?
Currently, supply chain attacks are one of the major security concerns all over the world. The secured_pip project is a future pip wrapper focused on supply-chain risk controls.
Wait, What?
You can use
spip install requests
Instead of
pip install requests
To install a package more safely in the scope of supply chain security.
You do not need to configure. You do not need to learn. Just pure install-to-master.
In other words, you can completely replace pip install with spip install to make your installation safer :)
Package manager support
secured_pip now has diversified package-manager support:
-
pip:spip install requests -
pipx:spip pipx install blackorspipx install black -
poetry:spip poetry add requestsorspoetry add requests -
uv:spip uv pip install requestsorsuv pip install requests -
conda: planned
You can guard common pipx, poetry, and uv package additions:
spip pipx install black
spip poetry add requests
spip uv pip install requests
The package also installs spipx, spoetry, and suv convenience entry
points, so spipx install black, spoetry add requests, and
suv pip install requests work the same way. Supported guarded commands are
pipx install, pipx inject, pipx run, poetry add, poetry self add,
uv pip install, uv add, uv tool install, and uv tool run. Other
non-install commands are passed through unchanged. Commands that would install
packages but cannot be translated into a pip install plan, such as
pipx upgrade, poetry add --source internal ..., or uv run ..., are refused
instead of running without checks.
If you want a near drop-in experience, you can set a shell alias from pip to spip.
Command Prompt (Windows):
pip install secured_pip
doskey pip=spip $*
Bash (Linux):
pip install secured_pip
echo "alias pip='spip'" >> ~/.bashrc
source ~/.bashrc
Zsh (macOS):
pip install secured_pip
echo "alias pip='spip'" >> ~/.zshrc
source ~/.zshrc
The secured_pip project will actively check for all the supply chain risks and avoid you installing potentially malicious packages when typing spip install
For install, secured_pip uses pip's own resolver and then checks the selected install plan before pip builds or installs the resolved distributions. If the checks pass, the same pip install flow continues; secured_pip does not run a second pip install for the already-resolved packages.
Except for the install commands, the project behaves exactly the same as the original pip program. That is, you can always use spip instead of pip in any case :)
For pipx, poetry, and uv, secured_pip runs a pip-compatible preflight
resolution and artifact check before handing control to the original tool. The
original tool still performs the actual environment update.
For more details, please see our docs: https://spip.lamentxu.top/docs
What problem do secured_pip solved?
Supply-chain poisoning has always been a persistent security problem. Existing solutions include mature but expensive-to-run tools like GuardDog, and lightweight tools like sfw that rely entirely on a paid Socket API. GuardDog is too heavy for everyday CI usage and is better suited to static analysis by security researchers. Running GuardDog against every artifact downloaded by pip install, including all dependencies, would slow installs down. sfw is lighter, but its dependence on a paid API creates another cost for everyday developers.
secured_pip solves this by hooking into pip's installer and merging security checks directly into the pip install download and installation flow. At the same time, the performance impact is usually small. secured_pip is completely free for everyone.
Today, many independent developers have suffered CI server compromises that leak secret keys and cause serious damage. With secured_pip installed, that risk is greatly reduced, while requiring no payment, no extra performance budget, and no learning or configuration. Install it once with pip install secured_pip, set an alias once, and keep using pip while gaining an important protection layer in the background.
Warning policies
TODO
Contributions welcome:
- Framework
- Support guarded
uv pip install,uv add,uv tool install, anduv tool run - Support guarded
pipx install,pipx inject, andpipx run - Support guarded
poetry addandpoetry self add - Support
conda
- Support guarded
- CI
- Write a benchmark CI in the github workflow to compare the performance of
spip installandpip install
- Write a benchmark CI in the github workflow to compare the performance of
- Documentation
- Use some modern documentation framework to refactor the /doc/docs directory.
- Support website view on mobile phones. @didongji91
- Checks
- Record and compare installed package entry-point and
.pthbaselines acrossspipinstalls- If new or changed
.pthfile is added - If entry-point metadata or script files change
- If new or changed
- Detect yanked releases from pip's resolved install report
- Compare archive hashes with already available PyPI release metadata
- Add check of the diff between the last version of the package and the to-be-installed version, search for malicious changes
- If setup.py has been changed
- Record and compare installed package entry-point and
We currently have three install warning policies:
HIGH: pause installation and require--spip-ignore-warningMEDIUM: prompty/nbefore continuingLOW: warn and continue
The default sensitivity is low, which uses the policy above. You can make
the gate stricter with --sensitivity medium or --sensitivity high:
--sensitivity medium:MEDIUMand above pause installation;LOWprompts.--sensitivity high:LOWand above pause installation.
Use --spip-ignore <level> to completely ignore warnings at that severity and below.
For example, --spip-ignore LOW suppresses LOW warnings, while --spip-ignore MEDIUM
suppresses both LOW and MEDIUM warnings. Ignored warnings are not printed,
and checks that can only produce ignored severities are skipped.
Caches
secured_pip stores PyPI name, release-time, and maintainer email history caches in
the user's cache directory by default, so the same cache is reused across projects.
Set SPIP_CACHE_DIR to override the cache directory.
Benchmark
Run the local benchmark with:
python scripts/benchmark_install.py --runs 5 --warmups 0
The default benchmark compares pip install ruff and spip install ruff,
timing package download and installation together. It uses --no-cache-dir,
--no-deps, and a fresh --target directory for each measured run, so the
result focuses on repeated installs of one well-known package body rather than a
dependency tree. The Benchmark GitHub Actions workflow runs on relevant main changes, on a
weekly schedule, or by manual dispatch. It publishes the latest
benchmark.json to the remote benchmark-data branch, and the website renders
x1.0742-style median ratios from that data. Benchmark updates do not advance
main.
When secured_pip detects a potential risk, a warning will be raised, with the level depending on the severity the risk is.
For now, the project has several major check points:
- Fake typo checks: Hackers often use "fake typos" to inject a malicious dependency package into the poisoned source file.
secured_pipdetects this by first resolving all the packages thatpip installis going to download, and then comparing non-popular resolved package names with a local hot-package list. Warning levels:- Medium severity:
requsetsvsrequests - Medium severity:
pandavspandas - Low severity:
sixthvssix
- Medium severity:
- Direct URL dependency checks: If the install target or a resolved dependency uses a direct URL, VCS URL, or PEP 508 direct reference,
secured_pipwill raise aMEDIUMwarning. - Fresh release checks: If the selected PyPI release was published less than 8 hours ago,
secured_pipwill raise aMEDIUMwarning; if it was published less than 48 hours ago,secured_pipwill raise aLOWwarning. - Yanked release checks: If pip resolves a release that is marked as yanked,
secured_pipwill raise aMEDIUMwarning using pip's install report. - Archive hash checks: If PyPI release metadata is already available and the selected wheel/sdist digest does not match the resolved archive hash,
secured_pipwill raise aHIGHwarning. - Empty description checks: If the selected PyPI release metadata has no summary and no long description,
secured_pipwill raise aLOWwarning. - Suspicious metadata URL checks: If PyPI metadata points to a shortener, raw IP, suspicious TLD, embedded credentials, or similar suspicious URL,
secured_pipwill raise aLOWwarning. - Repository mismatch checks: If PyPI metadata points to a GitHub/GitLab repository whose repo name appears unrelated to the package name,
secured_pipwill raise aLOWwarning. - Maintainer email domain drift checks: If a package's maintainer email domain changes compared with the local
secured_piphistory cache,secured_pipwill raise aLOWwarning. - Zero-version checks: If the selected package version is
0.0or0.0.0,secured_pipwill raise aLOWwarning. -
.pthfile detection: Instead of directly injecting malicious code inside the package, today most hackers will place their bad stuff under a.pthfile, with animportas the beginning.secured_piponly checks the installed file-system diff after installation. The warning level is alwaysMEDIUM, andsecured_pipwill ask whether to delete the suspicious installed.pthfile. - TODO ...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secured_pip-1.0.0.tar.gz.
File metadata
- Download URL: secured_pip-1.0.0.tar.gz
- Upload date:
- Size: 82.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0b2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79742797856b76dcd6b80935b2e86590b3caa2c8281b9edcfa3fd6e0e8a052b3
|
|
| MD5 |
e8f2510c1dd606038ac7b30467f12430
|
|
| BLAKE2b-256 |
1288b0f296fe725a1304f664b1081b82bde0779ca008564e07b37473bc4647f8
|
File details
Details for the file secured_pip-1.0.0-py3-none-any.whl.
File metadata
- Download URL: secured_pip-1.0.0-py3-none-any.whl
- Upload date:
- Size: 57.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0b2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7eb0e3c5ec7445529290af0ab025fc2ccf888c9466339213c761b0b95753923
|
|
| MD5 |
fe60cd6baf1c2036f1cacc8a19edaac1
|
|
| BLAKE2b-256 |
975af2da1c152fb8336ec9a933880bba1a6366ffadf0f0f7b506330af9232e23
|