Shai-Hulud returns to npm: keyv and flat-cache compromised, and cooldowns are your best defense
A new wave of the Shai-Hulud worm hit npm a few days ago. Attackers compromised the keyv and flat-cache package families. flat-cache alone has more than 500 million weekly downloads. Even if you do not declare these packages in your package.json, they can enter as a transitive dependency of another library.
The entry vector is the package manager's preinstall and postinstall scripts. The malicious script exports your credentials: npm, GitHub, AWS and Kubernetes tokens, and .env files. It is a worm attack: it uses the stolen npm token of another maintainer to publish infected versions and jump between dependencies.
First defense: the Dependabot cooldown. Security tools such as Aikido detect these packages in minutes, but they do not detect all of them. A cooldown of days puts new versions in quarantine until the ecosystem validates them. This week's news: the cooldown configuration for Docker Compose failed silently, and it is fixed since May 20. It does not support semver segregation yet, but the default value now works.
Second defense: use pnpm with policies that block provenance downgrades. Third: set a minimum release age in your .npmrc for manual updates. Codely dodged this one, and they say it without bravado: the next wave can hit anyone. Watch in the video.

All the news we covered