Skip to content

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 keep uv dependencies updated with Dependabot

Configure Dependabot to update uv.lock weekly, group minor and patch releases, delay new releases, and preserve useful version ranges.

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.

From the blog

Posts tagged security.

Last updated on