Security

Malicious npm packages: how they steal your secrets

How malicious npm packages steal tokens and env files, how typosquats and takeovers like Shai-Hulud on TanStack get in, and how to protect your project.

  • 6 min read
  • 5 questions
  • +35 XP
Transcript

Malicious packages, explained by cats. Kitty needs some code for her app. She doesn't want to write it herself. So she opens npm. Searches for a package. And finds one quickly. It looks safe. Nice description. Lots of downloads. Even a cute icon.

So Kitty installs it. The package looks normal. The install works. No red errors. It does the job. But behind the scenes, the package can run code. It can read env files. It can steal tokens. It might be a fake package with a name that looks almost right.

That’s a typosquat. Or it might be a real package that bad cats took over. Like the recent Shai-Hulud attack on TanStack. Kitty didn't notice and got compromised. That’s a malicious package. it sneaks into Kitty’s app through the front door.

And that’s what makes it dangerous. Kitty invited it in. But Kitty can’t inspect every package by paw. So Kitty uses Aikido Device Protection. Aikido watches what gets installed on her device. package registry, apps and even browser extensions. If something is known to be bad, Aikido blocks it before it's installed. Because a dangerous package doesn’t always look dangerous. Sometimes, it looks exactly like the package Kitty wanted.