Securing Your Python Supply Chain: From Dependencies to Deployment
Supply chain attacks targeting Python packages hit real projects with millions of users. The Ultralytics compromise injected a cryptocurrency miner into a package with 80 million monthly downloads. GhostAction stole 3,300+ secrets from 570+ repositories. The Shai-Hulud worm crossed ecosystem boundaries from npm to PyPI. These attacks exploited gaps that most Python developers leave open: unpinned dependencies, long-lived API tokens, no vulnerability scanning.
Your average Python project pulls in dozens of transitive dependencies you never chose. pip install flask gives you seven packages. If any one of them gets compromised, your application is vulnerable.
You can defend against these with tools available today. Ruff catches security bugs (hardcoded secrets, weak crypto, missing timeouts) before code leaves your editor. uv generates lockfiles with cryptographic hashes that detect tampering. pip-audit flags known CVEs in CI before they reach production. CycloneDX SBOMs let you answer "are we affected?" in minutes when the next compromise drops. Trusted Publishing eliminates long-lived PyPI tokens using short-lived OIDC credentials. Delayed ingestion with --exclude-newer gives the community time to spot malicious packages before you install them.
The session provides a phased adoption roadmap: start with linting and pinning for quick wins, add scanning and SBOMs next, then scale to advanced defenses as your security posture matures. All levels welcome.
This talk draws on experience maintaining several PyPA projects (tox, virtualenv, pipx, platformdirs, filelock) and working on corporate package hosting infrastructure. The speaker sees supply chain attacks from both sides: publishing to PyPI as an open-source maintainer and managing thousands of dependencies as an enterprise consumer. The material was delivered as a tutorial at PyTexas 2026; this proposal adapts it into a 25-minute talk.
Every defense strategy includes code or configuration that attendees can copy into their projects. A solo developer or small team can start with Phase 1 in an afternoon and see immediate results.
Software engineer at Bloomberg. Primary maintainer of tox, virtualenv, build, pipx, filelock, and platformdirs. Regular speaker at PyCon US, EuroPython, PyTexas, and PyLondinium since 2018. https://bernat.tech/about/