pkgscan.dev · Documentation
How to check an npm package for malware before installing it
Most npm malware is not a vulnerability. It is an install script or an obfuscated file that runs with your user's permissions. npm audit will not report it, because audit only matches known advisories. This page explains what pkgscan checks, what the result means, and what it still cannot see.
Updated 2026-11-05
Why npm audit is not a malware check
npm audit compares your dependency tree against the GitHub Advisory Database. A package that steals environment variables and posts them to a new domain usually has no advisory yet, so audit says nothing. The most common delivery mechanisms are:
- Lifecycle scripts.
preinstall,install, andpostinstallrun automatically duringnpm install, with the permissions of the user running the command. - Obfuscated first-party files. Base64 blobs passed to
eval, string-array obfuscators, or a small loader that fetches a second stage from a remote host. - Credential readers. Code that reads
~/.npmrc,~/.aws/credentials, SSH keys, browser profiles, or every environment variable and sends them out. - Compromised maintainer accounts and typosquats. A clean package name with one letter changed, or a trusted package hijacked through a stolen publish token.
- Protestware. Destructive code shipped by the maintainer themselves, which looks like a supply-chain attack from the consumer side.
Scan an npm package with pkgscan
You can submit an npm package three ways. All three return the same per-engine report, and every result is public — no account is needed to read it.
- Registry package. Paste
pkg:npm/[email protected]in the search bar, or open /pkg/npm/{name}@{version}. pkgscan downloads the exact version from the npm registry and scans the tarball. - Upload a tarball. Drop the
.tgzyou already have. Useful for private packages, a package you vendored, or a suspicious file from a mirror. - SHA-256 lookup. Open
/file/{sha256}to see whether that exact artifact was scanned before, and by which engines.
# Same report the web UI shows, from a script or CI job curl -s https://www.pkgscan.dev/api/pkg/npm/[email protected] \ -H "Authorization: Bearer pkg_YOUR_KEY" # Start a fresh scan of a registry package curl -s -X POST https://www.pkgscan.dev/api/scan/from-generic-purl \ -H "Authorization: Bearer pkg_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"purl":"pkg:npm/[email protected]"}'
Which engines run on an npm package
| Engine | What it contributes | Input it needs |
|---|---|---|
| Argus | Yeeth Security's content-analysis malware engine. Reads the code, not the package metadata. | Package bytes |
| GuardDog | DataDog's static rule set for install hooks, obfuscation, credential access, and exfiltration patterns. | Package bytes + npm identity |
How to read the verdict
pkgscan separates two questions that other scanners merge into one red badge: is this package malicious? and does this package have known security issues? Only Argus and SkillSpector are treated as malware engines. OSV, Grype, and deps.dev report vulnerabilities. GuardDog runs as a heuristic engine: its hits appear as security issues, not as a malware verdict.
Inspect a package yourself in one minute
# Download without installing or running scripts npm pack [email protected] --ignore-scripts # Read the lifecycle scripts without extracting the whole package tar -xzOf lodash-4.17.21.tgz package/package.json | python3 -m json.tool # Look at what a suspicious install script would touch tar -xzOf lodash-4.17.21.tgz package/package.json \ | grep -E '"(pre|post)?install"|\"main\"'
If the package has a postinstall, extract it and read the file it calls. Network calls to a bare IP, curl | sh, and base64-decoded code are the signals that matter most.
What pkgscan does not cover for npm
- It scans the package you submit, not your full transitive dependency tree. A clean direct dependency can still pull in a bad package.
- It does not execute the package. Dynamic behaviour, network callbacks at runtime, and environment-specific payloads are out of scope.
- Private registry packages must be uploaded as a tarball; pkgscan cannot authenticate to your registry.
- A published version can be replaced upstream. Pin the SHA-256 in your lockfile and use hash lookups when you need to verify the exact bytes.
Related: how pkgscan detects malicious packages, the detection provider comparison.
Check a package or file now: scan it on pkgscan.dev.