Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 5 min read

Waiting a week is the cheapest defence against hijacked PyPI releases. Enforce it for the whole team

On November 17, two malicious releases of Microsoft's agent-framework (1.26.1 and 1.26.2) went up on PyPI, at 20:35 and 21:08 UTC. Both are gone now (GHSA-764m-3ppc-5m73). Anyone who installed or upgraded in between got

Waiting a week is the cheapest defence against hijacked PyPI releases. Enforce it for the whole team

On November 17, two malicious releases of Microsoft's agent-framework (1.26.1 and 1.26.2) went up on PyPI, at 20:35 and 21:08 UTC. Both are gone now (GHSA-764m-3ppc-5m73). Anyone who installed or upgraded in between got a credential stealer.

That timeline is typical. An attacker gets a maintainer's token or a CI secret, publishes a poisoned release, and for a few hours every unpinned install pulls it. Then someone notices, the registry removes it, and the window closes.

The same pattern, again and again

  • litellm, March 2026. Versions 1.82.7 and 1.82.8 of a package with over 95 million downloads a month carried a stealer for SSH keys, cloud tokens and .env files. Both were removed from PyPI (BleepingComputer).
  • ultralytics, December 2024. The first malicious releases were published through the project's own GitHub Actions workflow after its cache was poisoned, the later ones with a PyPI token that was still valid. Versions 8.3.41, 8.3.42, 8.3.45 and 8.3.46 were removed (PyPI blog).
  • torchtriton, December 2022. A package on PyPI took the name of a PyTorch nightly dependency, and pip installed it instead of the real one. It sent SSH keys, .gitconfig and files from the home directory to its author (PyTorch). That one is dependency confusion, a different hole.

The idea: a cooldown

If nothing younger than N days can be installed, a release that is caught within N days never reaches you.

Kiell Tampubolon replayed 11,556 malicious npm and PyPI packages from 2026 against different cooldowns. For hijacked releases of real npm packages, waiting 1 day blocks 70.4%, 3 days 81.3% and 7 days 85.1%. For packages that were malicious from the start, such as typosquats, a 7-day wait still lets 45% through.

The cost is that fixes arrive late too: with a 7-day cooldown, 46.1% of security fixes in that data set would reach you after the vulnerability was public. So a cooldown needs an exception path for urgent security releases.

Per machine or per team

The tools already have the switch: uv has exclude-newer, pip 26.1 has --uploaded-prior-to P7D, Renovate has minimumReleaseAge and Dependabot has cooldown. Each works, but per developer, per project and per pipeline. The one laptop or CI job that skips it is the one that gets hit, and nobody can see from one place what the team is actually protected by.

For your own machine or repo, this is all it takes:

# pip 26.1+: ignore anything uploaded in the last 7 days
pip install --uploaded-prior-to P7D -r requirements.txt

# uv: the same, or exclude-newer = "1 week" under [tool.uv] in pyproject.toml
UV_EXCLUDE_NEWER="1 week" uv lock
# .github/dependabot.yml: Dependabot already waits 3 days by default, this makes it 7
# (security updates are never delayed)
version: 2
updates:
  - package-ecosystem: pip
    directory: /
    schedule:
      interval: weekly
    cooldown:
      default-days: 7

In Renovate it's one line, "minimumReleaseAge": "7 days".

Putting the rule into the package index instead applies it to everyone and every CI job at once, including tools that have no such option.

What I built

Coldwheel is a Terraform module that deploys a private PyPI index into your own AWS account. pip, uv and Poetry point at one URL. It serves your private packages, passes pypi.org through with the cooldown applied, and makes sure your private package names can't be taken over from pypi.org. With upload_enabled = true it also takes uploads from twine, uv publish and poetry publish. It's Apache 2.0, and the index never reports back to me what you install.

module "pypi" {
  source  = "coldwheel-dev/pypi/aws"
  version = "~> 0.2"

  upstream_cooldown_days    = 7                 # the default
  upstream_cooldown_exclude = ["my-public-lib"] # packages that skip the wait
}

How it works

How Coldwheel works

There are three AWS pieces and no server: an S3 bucket for your own wheels, a CloudFront distribution in front of it, and a small Lambda@Edge function that answers requests for the package pages of the simple index, /simple/<package>/. For each request it does three things, in this order:

  1. Basic Auth. Users and passwords live in AWS Secrets Manager. Laptops and CI jobs log in the same way, through .netrc, keyring or pip.conf.
  2. Your bucket first. If any file with that package name is in S3, only your files are listed and pypi.org isn't asked at all. That closes the hole torchtriton went through: a public upload can't shadow a private name.
  3. pypi.org, filtered. Otherwise the function fetches the project from pypi.org's JSON API (PEP 691), which carries an upload time for every file (PEP 700). It drops every file uploaded less than upstream_cooldown_days ago, and any file without an upload time, then returns an ordinary simple index page with the sha256 hashes intact.

Simplified, the whole cooldown is this:

def filter_cooldown(files, now):
    cutoff = now - timedelta(days=UPSTREAM_COOLDOWN_DAYS)
    return [f for f in files
            if f.get("upload-time") and parse_upload_time(f["upload-time"]) <= cutoff]

What your team sees

Mostly nothing. The index doesn't list the new release, so pip does what it always does and installs the newest version that's left. If a package had a release two days ago, pip install gets the one before it today and the new one once it's a week old. Nobody edits requirements.txt or changes their workflow.

Two things to know:

  • An exact pin to a release that is still in the cooldown fails with "Could not find a version that satisfies the requirement" until the week is up. That's on purpose: nobody skips the wait by accident.
  • The files themselves still download from files.pythonhosted.org. Only the package listing goes through your index, so you don't store or pay for pypi.org's packages, and your index password is never sent to PyPI.

When you need the fix today

Add the package to upstream_cooldown_exclude and run terraform apply. It takes effect when CloudFront's cached page expires, or right away if you invalidate /simple/*. Packages in your own bucket never wait.

Setup and cost

A machine needs one setting, plus the password in ~/.netrc or keyring:

# ~/.config/pip/pip.conf (or PIP_INDEX_URL in CI)
[global]
index-url = https://pypi.example.com/simple/

uv takes the same URL as its default index, Poetry as its primary source. For 5 GB of packages, 100,000 requests and 20 GB of downloads a month, the module's README puts the AWS bill at about $0.60 a month.

What a cooldown doesn't catch

The 45% above: packages that are malicious from day one and stay unnoticed for weeks. For those, waiting isn't enough; you need a list of known bad versions. I'm building such a feed as a paid add-on to Coldwheel; if you want to hear when it's ready, there's a waitlist at coldwheel.dev.

How does your team handle brand-new releases today, and what's your path for the "we need this CVE fix now" case?

I wrote this article with help from an AI assistant. The facts and numbers are checked against the linked sources, and the module is my own work.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.