A malicious package is a dependency that does the job you installed it for while quietly doing something harmful as well, such as reading your secrets and sending them to an attacker. It is dangerous because it doesn't look dangerous: it has a sensible name, a nice description, plenty of downloads and an install that finishes without a single red error.
Why packages are a way in
Modern apps are mostly other people's code. A web app might list twenty packages in its package.json, and those pull in hundreds more. Registries such as npm and PyPI let anyone publish, which is what makes them so useful, and also what makes them a target.
Installing a package is an act of trust. Its code runs on your machine, or in your CI pipeline, with the same access you have: your files, your environment variables, your network. A malicious package doesn't need to break in. You invite it in through the front door.
This is a kind of supply chain attack: instead of attacking your app directly, the attacker poisons something your app is built from.
How malicious packages reach you
There are two common routes.
Typosquats: a name that looks almost right
An attacker publishes a package whose name is one slip away from a popular one: a doubled letter, two letters swapped, a hyphen instead of nothing. One typo in an install command and you get theirs:
npm install expresss # one 's' too manyThe fake often works, because it simply copies or wraps the real package. Your app runs, your tests pass, and nothing looks wrong. The harmful part runs alongside.
Takeovers: a real package turned bad
The more dangerous route is a real, trusted package that attackers take control of. They might steal a maintainer's login or publishing token, or break into the project's build pipeline, then publish a new version with malware inside. Everyone who installs or updates to that version gets it, and every usual signal of trust, from the name to the download count, is genuine.
Wondering how this was made? How we make these