| Date: | 2026-05-03 22:43 |
|---|---|
| category: | Tech |
| tags: | python, security |
| summary: | Recent attacks on LiteLLM and PyTorch Lightning show how dangerous "bleeding edge" updates can be for your security. Use a seven-day time gate to ensure your packages are vetted by the community before they touch your code. |
In the last two months, the Python community has seen serious supply chain attacks.
In March, LiteLLM was compromised to steal credentials. Last week, PyTorch Lightning suffered a similar attack where malicious versions tried to steal cloud secrets and SSH keys.
In both cases, the bad code was found and removed quickly. However, anyone who updated their packages during those few hours was at risk.
To protect yourself, add these lines to your ~/.bashrc or ~/.zshrc file.
This tells your tools to ignore any package released in the last week.
# uv: Ignore any package versions released in the last 7 days
export UV_EXCLUDE_NEWER="7 days"
# pip: Ignore any package versions uploaded in the last 7 days
export PIP_UPLOADED_PRIOR_TO=P7DFor per-project constains, update pyproject.toml in the following way:
[tool.uv]
exclude-newer = "1 week"
exclude-newer-package = { "safezip" = "0 days" }In the example below, the safezip package is excluded from overal project exclude-newer containts of 1 week.
- The "Cooling Off" Period
- Most malicious packages are caught by security experts within 48 hours. A seven-day delay ensures that any code you download has been checked by the public for a full week.
- Stopping "Fast" Attacks
- The PyTorch Lightning attack lasted less than one hour. A one-week buffer makes these short-lived, poisoned releases invisible to your build system.
- Reliable Defence
- This prevents your update commands from accidentally grabbing a "bleeding edge" version that might be compromised.
By waiting seven days, you lose nothing important but gain a massive increase in security.
If only PyPI (and other registries, such as NPM) would start doing preventive scanning of uploaded packages, and only offer scanned/secure packages for download...