Pinned a package with pkg==1.2.3 and felt safe? Not so fast. PyPI allows uploading extra files to an existing release for 14 days, and @v7-style tags in GitHub Actions can be overwritten with a force-push. Another common CI hole is running uvx without a lockfile, pulling the latest release straight into an environment with your secrets.
Astral's security guide lays out concrete settings for uv and CI. In pyproject.toml, add a three-day cooldown on fresh releases (PyPI removes most malicious packages within 24 hours) and disable building from source distributions (sdist):
# pyproject.toml: 3-day cooldown and prebuilt wheels only
[tool.uv]
exclude-newer = "3d"
no-build = true
If a required library lacks a prebuilt wheel, add it to no-binary-package. Move CI tools and PEP 723 scripts onto lockfiles with UV_LOCKED=1:
# Pin a CI tool in the lockfile instead of running unpinned uvx
uv add --group nox nox
uv run --locked --only-group nox --isolated nox -s lint
# Lock dependency hashes for a PEP 723 script
uv lock --script scripts/check.py
Lock down the rest of your GitHub Actions pipeline the same way: pin actions to full commit SHAs (using pinact and the zizmor linter), verify binaries with sha256sum -c or hashlib.file_digest in Python 3.11+, and publish packages via uv publish with Trusted Publishing instead of static tokens.

