---
title: "Malicious packages"
description: "How TRUSTIVAN flags packages published as malware, suspected typosquats of popular package names, and npm packages that run install scripts."
---

A malicious package is not a flaw in useful code: it is the attack. It
usually has no CVE, so a scanner that matches CVEs never reports it.
TRUSTIVAN checks every package a scan inventories against published malware
advisories, and checks npm and PyPI names for near misses of popular packages.

## Malware advisories

The worker reads OSV's advisory archives (`npm`, `PyPI` and `Go` by default)
once a day and keeps two kinds of record:

- **`MAL-` records** from [ossf/malicious-packages](https://github.com/ossf/malicious-packages),
  where security vendors and registries report packages found to be malware.
- **GitHub advisories classified CWE-506** (Embedded Malicious Code), GitHub's
  "this package is malware" class.

A package whose name and version an advisory covers becomes a **critical**
finding identified by the advisory (`MAL-2025-25502`), with `detail.malicious:
true`, whatever its CVE record says. If the scanner already reported the same
advisory under a CVE alias, that finding is marked instead of a second one
being added. The [risk score](/concepts/risk-scoring) adds 60 points, and none
of the reductions for a development dependency, the image's entrypoint or
reachability apply: an install script runs on every machine that installs the
package, which is how most malware acts.

**What to do:** remove the package, and treat every machine that installed it
(developer laptops, CI runners, build images) as exposed: rotate the
credentials those machines held.

A withdrawn advisory is ignored. A package an advisory stops covering is
resolved at the asset's next scan, like any finding the scan no longer
observes.

## Suspected typosquats

Typosquats are published under near-miss names to catch a mistyped install.
An npm or PyPI package is flagged when its name is not among the 5,000
most-downloaded packages in its registry and is:

- one character added, left out, changed, or two adjacent characters swapped,
  against one of the 2,000 most downloaded with five or more characters
  (`lodahs` for `lodash`, `urlib3` for `urllib3`);
- the same name once separators are removed (`crossenv` for `cross-env`) or
  look-alike characters are folded (`0` and `o`, `1`, `I` and `l`, `rn` and `m`);
- a popular name with `js`, `node`, `py` or `python` glued on (`chalk-js`,
  `python-requests`).

The finding's identifier is `TRUSTIVAN-TYPOSQUAT`, its severity **medium**, or
**high** when the lock file records an install script, and
`detail.typosquat` names the package it resembles and the edit. It scores 20
points in the risk score. A package that is both malware and a typosquat is
one finding carrying both.

This is a heuristic. Measured on 2026-11-14 against the packages ranked 5,001
to 15,916 by downloads, which are legitimate and just below the cut-off, it
flagged **0.7%** of npm names (71 of 10,916, such as `echarts` for `recharts`)
and **1.5%** of PyPI names (154 of 10,000, such as `nvidia-nccl-cu11` for
`nvidia-nccl-cu12`). Against the 12,045 PyPI packages with an OSV `MAL-`
record it flagged **7.0%**: most malware does not use a near-miss name, which
is why the advisory feed is the main check. Suppress a finding for a package
you meant to depend on.

The popular-package lists ship with TRUSTIVAN (npm from `npm-high-impact`,
PyPI from `hugovk/top-pypi-packages`), so the check runs offline and gives
the same answer everywhere.

## Install scripts

npm records in `package-lock.json` which packages run a `preinstall`,
`install` or `postinstall` script (`hasInstallScript`). Every vulnerability
finding on such a package carries `detail.install_script: true`, and a
suspected typosquat that runs one is raised to high.

TRUSTIVAN does not check who published a version or how recently a package
changed maintainers: that needs the registry's metadata at scan time, which an
offline scan does not have.

## Configuration and status

| Setting | Default | Effect |
|---|---|---|
| `OSV_SOURCE` | `url` | `url` fetches `<OSV_URL>/<Ecosystem>/all.zip` (npm's is about 210 MiB, streamed to a temporary file); `file` reads `OSV_DIR/<Ecosystem>/all.zip`, the air-gapped configuration; `none` turns malware advisories off. Typosquat checks need no data and stay on |
| `OSV_ECOSYSTEMS` | `npm,PyPI,Go` | Which archives are read. `Go` supplies the vulnerable functions for [reachability](/concepts/reachability) |

`GET /api/v1/system/status` reports the feed as `malicious_packages`: when it
last loaded, how many records it holds, whether it is stale and the last
error. Until it has loaded once, the risk factor says "not checked", never
"no malware advisory". The backlog's **Malicious** filter
(`malicious=true` in the API) appears once the feed has loaded.

## Limits

- Advisories are matched when a scan runs. A package that is reported as
  malware after the last scan of an asset is flagged at its next scan, not
  before.
- Only packages the scan inventories are checked: lock files and manifests in
  a repository or image. A package installed by a script at build time and
  not recorded anywhere is not seen.
- OSV records carry their source's licence: ossf/malicious-packages is
  Apache-2.0, the GitHub Advisory Database and the Go vulnerability database
  are CC-BY-4.0. Each finding links to its OSV record.
