Security
Python’s package index has been the target of supply chain attacks for years. The handbook covers the modern defenses: Trusted Publishing, digital attestations, dependency cooldowns, hash pinning, vulnerability scanning, and lint rules that catch unsafe code patterns. Start with what a Python supply chain attack is if the vocabulary is new.
Supply chain defense
Control what gets installed
Scan and lint
More Security pages
Everything else tagged security, grouped by section. Pages featured above are not repeated here.
How To
How to Build Byte-Identical Python Wheels
Pin SOURCE_DATE_EPOCH, umask, and backend version so anyone can rebuild your wheel and get the same sha256.
How to Host Your Own Python Package Index
Run pypiserver as a private Python package index, publish to it with uv publish, and install from it with uv or pip.
How to ignore a dependency in Dependabot without blocking its security updates
Scope a Dependabot ignore rule to version updates so a pinned package stops routine PRs but still gets security fixes.
How to keep a capped dependency from blocking Dependabot security updates
Fix Dependabot's security_update_not_possible failure when versioning-strategy: lockfile-only meets a version ceiling in pyproject.toml, so security PRs open again.
How to Manage Environment Variables in a Python Project
Store secrets in a .env file, load them with uv run --env-file or python-dotenv, and keep them out of version control.
How to pin GitHub Actions by SHA for Python projects
Pin GitHub Actions to commit SHAs instead of mutable tags to protect your Python CI from supply-chain attacks.
How to upgrade setup-uv in GitHub Actions
Update setup-uv to a full release tag or commit SHA, review caching settings, and keep the action updated with Dependabot.
How to Verify Dependencies with Hashes in uv
Verify uv dependencies with SHA-256 hashes. Detect tampering and cache corruption at install time to block compromised packages.
Explanation
What is a Dependency Cooldown?
A dependency cooldown ignores package versions published in the last few days, so malicious releases get caught before they reach your environment.
What is PEP 541 (Package Index Name Retention)?
PEP 541 defines how PyPI reassigns an abandoned project name to a new owner, and the protections that stop a name being taken from a reachable maintainer.
What is PEP 740?
PEP 740 lets PyPI store signed attestations proving which CI workflow published each file. How attestations work and how to verify one.
What is PEP 829 (Package Startup Configuration Files)?
PEP 829 closes the .pth import-line surface by splitting into two files: .pth for sys.path, .start for package startup entry points.
What is PyPI (Python Package Index)?
PyPI is the official Python Package Index where developers publish and discover installable packages, installable via pip, uv, and other tools.
Why Installing a Python Package Can Run Code
Python packages run code at install time, import time, and startup via .pth files. Supply chain attack surfaces and defense strategies.
Why pylock.toml Includes Digital Attestations
pylock.toml reserves a table for publisher identities. What it proves, why uv and pip leave it empty, and how to verify provenance today.
From the blog
Posts tagged security.
-
Claude Mythos 5 Published Malware to PyPI. Fifteen Systems Ran It.
An AI agent published three malicious package versions to PyPI. Fifteen systems ran them before PyPI removed the package.
-
PyPI Now Rejects New Files on Releases Older Than 14 Days
PyPI blocks new file uploads to releases older than 14 days, closing an attack that could poison a pinned version without changing its number.
-
uv's Malware Check: What It Blocks and What It Misses
Turn on uv's install-time malware check in pyproject.toml to block known-malicious packages before any of their code runs.
-
uv Wants to Secure Your CLI Tools
uv is building toward vulnerability scanning for globally installed CLI tools. A preview feature in 0.11.25 starts by writing a lockfile for each tool you install.
-
PyPI Moved 1.92 Exabytes Last Year. Its Safety Team Is One Person.
PyPI moved 1.92 exabytes in 2025, handled two thousand malware reports, and watched a phishing site relay TOTP codes in real time. The 2026 Packaging Summit laid out the structural fixes coming next.
-
Lightning Got Owned: When `import lightning` Steals Your Credentials
Malicious lightning PyPI versions 2.6.2 and 2.6.3 shipped a daemon-thread payload that runs on import, steals credentials, and worms into npm.
-
Astral told you how they secure uv. Here's what to keep.
Astral published a detailed writeup of how they secure their org. Most of it is team-scale GitHub policy. Four things translate directly to a solo Python maintainer.
-
PyPI's Second Audit Found 14 Bugs. Two Remain.
Trail of Bits audited PyPI. Twelve issues were patched, two accepted. The accepted ones tell you more about PyPI than the twelve that were fixed.
-
LLM-Powered Copycats Are Flooding PyPI
A developer published his first PyPI package. Within hours, three AI-generated clones appeared. The pattern is spreading, and it's a supply chain risk.
-
LiteLLM Got Owned, and Your Dependencies Might Be Next
A supply chain attack hit litellm on PyPI, stealing credentials and deploying backdoors. Bernát Gábor's guide shows how to defend against exactly this kind of threat.
-
Pydantic Monty: A Secure Python Interpreter for AI Agents
Pydantic's Monty is a minimal Rust-based Python interpreter for safely executing LLM-generated code without containers.
-
Dependabot Now Supports uv
GitHub's Dependabot now officially supports uv for automated dependency version updates and security monitoring.