返回资讯中心
外部精选
软件工程
#开发者实时流

Cooldown or compromise: the three-day rule for NPM and PyPI

A dependency cooldown tells a package manager not to select registry releases younger than a set age. A three-day window can give maintainers and security researchers time to identify a compromised npm or PyPI release b…

Hacker News 最新6467543752026/10/15 · 2026/10/1530 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Oct 15, 2026

By: Bas van den Berg and Jos Huiting

-->

-->

A dependency cooldown tells a package manager not to select registry releases younger than a set age. A three-day window can give maintainers and security researchers time to identify a compromised npm or PyPI release before it enters your project. It is not a malware scanner, it cannot protect against malicious versions already approved or locked, and it can delay urgent security patches. Put the setting in the repository, commit a lockfile and define a reviewed emergency-update path.

A malicious package does not have to wait for your application to run. In npm, installation can trigger it. In Python, building, importing or starting the interpreter can trigger it. This depends on how the package was tampered with. By the time someone notices, a developer laptop or CI runner may already have handed over credentials. So can we avoid installing a release during its riskiest first few days?

We recommend a three-day release-age gate for registry packages, backed by a committed lockfile and a process for urgent security updates. In this article, we explain why, show where to configure it, and point to the gaps it cannot close. Also, we have published an auditable supply-chain skill that checks whether the settings are in place.

Shai-Hulud first appeared in September 2025. Then it returned in later npm campaigns. Its November 2025 wave affected 796 unique npm packages. Other npm and PyPI compromises followed in 2026. This includes malicious Lightning and Microsoft durabletask releases.

Now, a fresh version can move from a registry into a real development environment before a security team has had time to assess it. This is the narrow window a cooldown is designed to address.

A self-replicating worm has been moving through package registries such as npm and PyPI, hitting unsuspecting developers and exfiltrating credentials: CI/CD secrets, API keys, and tokens for OpenAI, GitHub, Microsoft, SAP, Red Hat, Bitwarden and Mistral AI. The worm’s moniker is ‘Shai-Hulud’, like the giant sand worms from Dune.

The first two waves were followed by other attacks in April and May 2026, leading up to the Megalodon attack and the most recent Shai-Hulud on 4 August 2026. In just under a year, this attack went mainstream. Reading through the attacks shows how fast exfiltration happens once the package manager downloads a compromised package.

These attacks are highly effective. So we expect more of them.

The fix itself is easy to apply. But it is buried in the documentation of the package managers: set a minimum age before a version is eligible for installation.

The specifics differ per manager and it can be a hassle to track down all the right steps. So we have summarised the gotcha’s, do’s and don’ts into a skill, which we are releasing together with this article.

Shai-Hulud is so effective because compromised packages run their malicious code as soon as the package is pulled in.

npm packages can execute lifecycle scripts such as preinstall and postinstall during installation, before your application imports them. A pipeline that scans after installing dependencies may therefore run too late. A package that fails at a later stage of installation may still have executed an earlier lifecycle script. Script execution depends on the package and the package manager’s settings; it is not true of every npm download. See npm’s script documentation.

On npm, the payload can run during several hooks such as preinstall and postinstall. preinstall runs before installation completes. It even runs when the install fails, but does not have access to the unpacked tarball. postinstall runs with npm ci, and has access to the unpacked tarball. So it can load additional malicious files. A scanner used by CI/CD pipelines is already too late, because the payload had run first using either of these hooks.

On PyPI, it does not even need an install hook. Starting python is enough. A *-setup.pth file dropped into site-packages executes at Python interpreter startup and runs the payload from there. Another way to backdoor packages is to add malicious code to init.py. This was done for backdoored versions of Lightning (2.6.2 and 2.6.3), published on 30 April 2026.

This also means that a wheels-only policy does not help protect against these backdoored packages. Importing the package executed start.py out of a hidden _runtime directory and ran an eleven-megabyte obfuscated JavaScript stealer called router_runtime.js. Snyk flagged it about eighteen minutes after publication, and traced the same payload to the npm campaign of the day before.

None of the attacks we looked at started with a clever exploit. The chalk and debug maintainer lost their account to a phishing mail spoofing npmjsa.]help, which collected a username, a password and a live TOTP code, allowing the attackers full access to the account. These packages have thousands of daily downloads. It makes them a juicy target.

Once the payload ran, it exfiltrated credentials. Microsoft’s durabletask is the clearest published example we have. Three malicious versions were published on 19 May 2026, carrying fourteen lines of injected Python that ran at import time, activated only on Linux, and dropped a 28KB payload into /tmp.

Microsoft pulled the packages the same day. The attack window was just a little bit over half an hour.

StepSecurity took the payload apart, and showed what the second stage could exfiltrate:

The filesystem collector worked from a list of 99 hardcoded credential paths, on laptops and CI runners, and the secrets were gone before anyone was even aware of the attack.

Another issue is removing the artifacts after being hit with compromised packages. Several waves of Shai-Hulud modified Claude Code hooks and VS Code auto-run tasks to gain persistence, leaving router_runtime.js and setup.mjs behind in .claude/ and .vscode/, where they survive npm uninstall. One variant ran a gh-token-monitor daemon that polled every sixty seconds and fired rm -rf ~/ when it detected that a token had been revoked.

Still, we’d argue that revoking and rotating the credentials and secrets should always have priority. A laptop can be replaced.

This raises a question we didn’t have to ask two years ago. Who is running npm install on your machine?

For better or worse, LLM coding agents have taken off in the past two years. And dependencies now get added by LLM coding agents when performing their tasks.

A coding agent can add a dependency even when no one has asked it to install a package. It decides the package will help complete the task, then asks the package manager to find a compatible version. Without a release-age rule, this could be a version published only minutes ago. If the release is malicious and its code runs during installation or use, the developer’s machine or CI runner may be compromised before anyone has reviewed the new dependency.

The malware authors use these LLM coding agents in their attacks: durabletask enumerated Claude Desktop, Cursor, VS Code, Zed, Codeium and Continue. AI tooling is a collection target and a persistence location, as the .claude/ artifacts above show.

Can’t we just tell the model to be careful? Sure, but instructions live in a context window. They can be summarised away, buried under forty turns of conversation, contradicted by a later request, or simply not followed. On the other hand, a package manager configuration is a hard technical constraint. The agent inherits it without being told it exists, and it cannot be talked out of it. The model does not need to understand supply chain security. It just has to be unable to install the compromised version in the first place.

Luckily, there is an easy fix. Configure your package manager to refuse any version published less than three days ago.

This prevents installation of malicious packages by both humans and agents. There is no signature list to maintain and no scanner that has to stay ahead of the attacker. The constraint is in the tool itself.

A cooldown works because compromised package gets detected before it can be installed. The latest version is held back. Much of the detection pipeline is automated, because registries and security vendors scan everything that gets published. For instance, the npm registry is heavily monitored by security firms such as Wiz. The rest of the detection can come from the compromised maintainers themselves, who find out that their account had published something they did not write.

Waiting a few days before installing a new package costs very little.

Almost no package has to be from the bleeding edge, except security patches, which are unfortunately also held back by a cooldown. Npm’s own documentation says so: when the window stops npm audit fix from installing a patched version because the fix went out too recently, npm keeps the package at its vulnerable version.

We decided on a three-day cooldown period to make sure that there is proper time to intervene, so despite weekend and/or holidays there’s still enough time for detection in case the automated scanners miss something. The detection times of the incidents are all short. Lightning was flagged in about eighteen minutes. Chalk and debug were live for roughly two hours on 8 September 2025. The Shai-Hulud 2.0 packages were unpublished across a single morning on 24 November 2025. In most cases, one day was enough to identify and remove the malicious packages.

A cooldown of just one day already handles most, if not all, of the attacks. The extra days are insurance against the next campaign’s detection time rather than the last one’s, and they are cheap because the only difference is that delayed patch.

pnpm shipped a one-day cooldown as the default in version 11, in late April 2026. If you are on pnpm 11, you already have a day of cooldown without configuring anything.

GitHub made a three-day cooldown the Dependabot default in July 2026, reasoning that new releases are a common supply chain entry point where a compromised version reaches your updates before the community has caught it. OpenAI reached for minimumReleaseAge after the Axios compromise.

Other package managers followed suit. uv, npm and Poetry all have a minimum release age in some form or another but it is not on by default.

Dependabot took an interesting route. Its cooldown applies to version updates only, and security updates are still applied immediately, so a critical fix is never delayed. It can make that distinction because it knows which updates are security updates. A package manager resolving a dependency graph does not, because a patched version and a poisoned version look identical to npm install.

So at the package manager level, the tool is per-package exemption. Every manager we checked has one: min-release-age-exclude on npm (names or minimatch globs), minimumReleaseAgeExclude on pnpm, exclude-newer-package in uv, and solver.min-release-age-exclude in Poetry.

Keep these lists short, and keep them to packages you publish yourself. This way, your critical patches of things you develop in-house still get applied right away.

It is possible to configure cooldowns globally so they passively protect every invocation of pip or uv, by both humans and LLM coding agents.

There is another issue, however. A cooldown filters candidate versions at resolution time only.

Resolution happens wherever somebody or something runs an install, so the setting has to be configured for both developer laptops and CI runners. Your laptop may read the global ~/.npmrc or ~/.config/uv/uv.toml but a fresh CI runner has no home directory and reads neither, so unless the setting is committed to the repo, CI resolves the dependencies regardless of how carefully you configured your own machine and still gets compromised.

T

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →