People like to bash vibe coding for generating insecure code. But there's another risk that almost no one talks about: you can get hacked before you even push your code to production, because your AI coding agent installed a compromised package.
Here's why that matters more than it sounds. When your AI installs a package, it can run code on your computer right away. Not your app—your actual computer. The one with your API keys, the passwords sitting in your project files, and your browser logged into everything.
How bad packages end up on your machine
When AI is generating code, it installs packages (e.g. reusable building blocks of code) from the internet. Sometimes it makes up a package name that doesn't exist, and hackers register those made-up names ahead of time to catch unsuspecting people. There's a name for this now: slopsquatting. It's the AI version of typosquatting, where hackers register misspellings like reqeusts and wait for someone to fat-finger it.
You could try to look up each package before your AI installs it (tedious!), but you still wouldn't catch the thing that's getting more common: popular, well-known packages getting hacked. See TanStack Router and LiteLLM. Both were real packages that lots of people trusted. Checking the name wouldn't have saved you.
So how can you protect yourself? With more software, of course!
I've been thinking a lot about this problem as the creator of Dyad, an open-source AI app builder that runs on your desktop computer. Because Dyad runs on your computer (like Claude Code, Codex, etc.), I wanted to make sure our users stayed safe without needing to tediously check every package or configure complicated settings just to get things safe by default.
Here are three things we did in Dyad. You can use these tips for any AI coding tool.
1. Use Socket Firewall to block malicious packages before they install
Socket Firewall is an awesome free tool that checks whether a package and all of its indirect dependencies (e.g. all of the packages that get indirectly pulled in when you install one package) are safe, and blocks it at install time.
That indirect part is the important bit. The package you asked for often isn't the one that hurts you.
Dyad automatically installs all npm packages with Socket Firewall, so you don't need to do anything to configure it.
2. Don't install the latest packages
This might sound counterintuitive. Shouldn't you install the latest version so you get all the latest fixes?
The thing is that when a package gets compromised, it usually takes security researchers hours to discover it and for npm to take the bad version down. Almost all of the damage happens in those few hours. So if you just don't touch anything published in the last day, you skip that window entirely.
You can do this yourself by configuring something like pnpm's minimum release age. It's a real-world defense, not a theoretical one: it would have helped against TanStack, LiteLLM, and a bunch of others.
Dyad enables pnpm v11 for its users by default, which automatically enforces a one-day delay.
You're trading a small amount of freshness for a big reduction in risk.
3. Block install scripts by default
Did you know that when you install an npm package, it can automatically execute code immediately after installation? This is a big security risk that hackers love, because it means they can steal your secret keys just from installing the package.
This is why pnpm automatically disabled postinstall scripts in v10. The problem, though, is that you need to remember to actually be on pnpm v10 or later. This is why, in Dyad, we nudge all of our users to use an up-to-date version of pnpm.
Stay safe
Honestly, the hardest part isn't any one of these settings. It's doing all of them, on every project. That's the whole reason we made them the default in Dyad instead of writing a docs page about it.
Hopefully you picked up a few practical tips! If you want all of these on by default without thinking about it, try downloading Dyad. It's free, open-source, and it does all three out of the box.
Let me know what you think. Do you have any tips for vibe coding safely?