5 npm security rules every team should enforce today
npm supply chain attacks are recurring operational risk, not a rare anomaly. Maintainer takeovers, typosquats, install-script malware, protestware, and vulnerable versions continue to hit widely used packages.
Teams need controls that run before code reaches laptops and CI. nproxy evaluates package requests at fetch/install time and can block or warn before dependency resolution completes.
Published April 2, 2026
Real incidents this maps to
- 2018-09-09 -
event-stream@3.3.6introduced a malicious dependency path throughflatmap-stream. - 2021-10-22 -
ua-parser-js@0.7.29,0.8.0, and1.0.0were published with malicious install-stage behavior. - 2022-01-05 to 2022-01-08 -
faker@6.6.6andcolors@1.4.44-liberty-2sabotage releases caused widespread CI failures. - 2022-03 -
node-ipcprotestware behavior appeared in releases including10.1.1,10.1.2, and9.2.2. - 2026-03-24 - another wave of npm typosquat packages targeting crypto developers was publicly reported.
One-minute setup before policy enforcement
These commands were validated against the current CLI help output.
npx @nproxy/cli setup acme-securitynpx @nproxy/cli verify acme-securitynpm install <package> \
--registry=https://acme-security.nproxy.app/This post is framed as five controls. The fifth combines two rule engines: malware and vulnerability. That gives coverage across six high-signal install-path checks.
Rule 1: Quarantine brand-new package names
Use first_seen in block mode. This catches new package names in a quarantine window (default 7 days), which is where many typosquat and short-lived malware campaigns operate.
Typosquats rely on newly created package names that are easy to miss in review. Quarantining brand-new names cuts off this attack path early.
$ npm install crossenv --registry=https://acme-security.nproxy.app/
BLOCKED crossenv@1.0.0 - first_seen: package created 2 days ago (threshold: 7)
resolution failed - blocked package in dependency graphRule 2: Flag publisher identity changes
Use publisher_change in warn mode at minimum. Sudden maintainer/publisher shifts are a known precursor to supply chain abuse.
event-stream changed publisher before the malicious dependency chain was introduced. This is exactly the anomaly this rule is meant to surface.
$ npm install event-stream --registry=https://acme-security.nproxy.app/
WARN event-stream@3.3.6 - publisher_change: publisher changed from dominictarr to right9ctrl
install proceeds (warn mode)Rule 3: Alert on unexpected dependency additions
Use unexpected_deps to detect versions that add new dependencies not present in prior releases. This catches dependency injection patterns.
event-stream introduced a new dependency, flatmap-stream, which carried the malicious payload. A dependency-shape delta is often the first high-signal clue.
$ npm install event-stream@3.3.6 --registry=https://acme-security.nproxy.app/
WARN event-stream@3.3.6 - unexpected_deps: new dependency flatmap-stream not present in prior versions
install proceeds (warn mode)Rule 4: Detect install-time script execution
Use install_scripts to surface lifecycle hooks (preinstall, postinstall, etc.) that execute code during package install.
Malicious ua-parser-js versions added preinstall behavior. Teams with install-script visibility would have had an immediate signal in the install path.
$ npm install ua-parser-js@0.7.29 --registry=https://acme-security.nproxy.app/
WARN ua-parser-js@0.7.29 - install_scripts: package defines preinstall script
install proceeds (warn mode)Rule 5: Block known-bad versions (malware + vulnerability)
Keep malware and vulnerability in block mode. This provides hard enforcement for known malicious versions and published CVEs.
When threat intelligence marks a version as malware/protestware, the malware rule can block it. When an advisory is published (for example, CVE-2021-4229), the vulnerability rule can block affected versions by severity policy.
$ npm install node-ipc@10.1.2 --registry=https://acme-security.nproxy.app/
BLOCKED node-ipc@10.1.2 - malware: version flagged by threat intelligence
$ npm install ua-parser-js@0.7.29 --registry=https://acme-security.nproxy.app/
BLOCKED ua-parser-js@0.7.29 - vulnerability: GHSA-pjwm-rvh2-c87w (CVE-2021-4229, HIGH)Where colors/faker fits in this model
colors/faker was maintainer-authored sabotage, not a publisher takeover. That incident is a good reminder to use layered controls and avoid single-signal dependence.
- Keep known-bad blocking (
malware,vulnerability) always on. - Keep behavior-anomaly detection on (
publisher_change,unexpected_deps,install_scripts). - Use
first_seento suppress fresh package-name risk where typosquats usually land first.
No rule set guarantees zero malicious packages. The goal is risk reduction by enforcing policy before dependency resolution completes.
- npm incident report: event-stream compromise (2018)
Maintainer transfer timeline and flatmap-stream payload details.
- GitHub Advisory: GHSA-pjwm-rvh2-c87w (CVE-2021-4229)
Affected ua-parser-js versions and remediation versions from October 22, 2021.
- ua-parser-js incident thread
Maintainer and community incident timeline for malicious publish window.
- npm blog: crossenv malware on npm
Typosquatting malware example where a lookalike package name was weaponized.
- BleepingComputer: node-ipc protestware coverage
March 2022 coverage of destructive protestware behavior in node-ipc releases.
- Snyk: colors and faker incident analysis
Breakdown of the January 2022 maintainer sabotage event.
- nproxy docs: Security Rules
Rule defaults and behavior for block/warn policy modes.
- nproxy docs: CLI setup
Current command syntax for nproxy CLI setup and onboarding.
Stop risky packages before they reach production
Put npm policy checks in the install path today and keep your existing developer workflow.
npx @nproxy/cli setup your-org-slug