AI Compass / Knowledge cards
Securing package updates
pin your versions, then wait
A supply-chain attack doesn’t target you directly, but a package you trust. The attacker publishes a new version with malware, and anyone who automatically installs the latest version picks it up. In Python, a startup file ending in .pth is all it takes: Python reads it every time it starts and runs any line in it that begins with import, even if your program never uses the package.
What it is for
Most poisoned versions are noticed quickly and blocked, often within minutes or hours. If you pin your versions and only adopt new ones after a short delay, you stay out of that window.
Steps
- Pin versions: list every package with an exact version number, such as
package==1.2.3inrequirements.txt, or use a lock file that records all versions. - Enforce hashes: a hash is a fingerprint of the file. With
pip install --require-hashes -r requirements.txt, pip only installs files whose fingerprint matches your list. For this to work, every package has to be listed with a fixed version and a hash. - Update with a delay: only adopt new versions after a few days. The uv tool can do this for you: with the
exclude-newersetting and a duration such as1 week, it only takes files uploaded before that point. - Apply updates deliberately: update on purpose and read what has changed first, instead of blindly pulling the latest version on every run. This matters most for automated workflows such as CI pipelines.
- Keep secrets to a minimum: give an environment only the credentials it really needs. What isn’t there can’t be stolen.
- If in doubt, don’t start Python: every start, including
pip, can trigger the malware again. Search the file system for the reported files instead, rebuild the environment and replace every credential that could be reached from it.
Limits
- Pinned versions only protect you from new poisoned versions. If the version you pinned is already poisoned, it doesn’t help.
- A hash only shows that the file is the same as when you listed it. It doesn’t show that the file is clean.
- Waiting only helps if the case is discovered in that time. According to StepSecurity, each poisoned agent-framework version was available for about half an hour at most; LiteLLM’s own report puts its window at around two hours. That’s no guarantee for other cases.
- My take: with a delay, security updates also reach you later. If a flaw is urgent, apply that update deliberately and sooner.
Links
- Vet third-party skills before they run: a skill also brings outside code that runs with your permissions.
Sources
- pip: Secure installs, accessed 19.11.2026 (hashes with
--require-hashes, pinned versions as a requirement) - Python: site — Site-specific configuration hook, accessed 19.11.2026 (
importlines in.pthfiles run at every start) - uv: Settings, exclude-newer, accessed 19.11.2026 (only files uploaded before a point in time or a duration)
- StepSecurity: Microsoft agent-framework PyPI Package Compromised, 18.11.2026 (time windows for 1.26.1 and 1.26.2, checking without starting Python)
- LiteLLM: Security incident: litellm 1.107.0, 21.10.2026 (window of around two hours)
Status
Checked 19.11.2026 · Maturity proven · Pinned versions and hashes have been documented pip features for years; the uv setting is newer, so check it in your own version before relying on it.
You can try this with your team in the AI Lab. See the AI Lab