Security Playbook
23 · Cloud & supply chainOWASP A03:20257 min read

Software supply chain: other people's code in your build

A typical web app pulls in hundreds of packages, each able to run code at install time. Typosquatting, hijacked maintainers and dependency confusion turn that trust into an attack path. The practical defenses, and what an SBOM is for.

In one sentence

Pin versions with a lockfile and npm ci, restrict install scripts, review new dependencies and updates, keep an SBOM, and give your build as few secrets as possible.

Three ways a malicious package gets in

Malicious packages: how they get into your build
Attack

A popular package's maintainer is phished. Version 4.2.1 ships with a credential stealer; ^4.2.0 in your package.json picks it up on the next install.

your-app
├─ express@4.21.2
├─ popular-lib@4.2.1   ← compromised release
│  └─ postinstall: node steal.js
└─ zod@4.6.7
Result in CI

✕ Install script ran in CI: npm token and cloud credentials stolen

Your app is mostly other people's code. Pin exact versions with a lockfile, install with npm ci, restrict install scripts, review new dependencies, and give CI the fewest secrets possible.
Pick an attack and switch on the controls that stop it.

A practical baseline

PracticeStops
Commit the lockfile, install with npm ci (no silent upgrades)Surprise malicious releases picked up by ^ranges
ignore-scripts by default, allowlist the few packages that need themMost install-time payloads
Review new deps: age, downloads, maintainers, repo link; delay brand-new versions a few daysTyposquats and freshly hijacked releases
Scoped registry config for private packagesDependency confusion
Automated updates (Dependabot / Renovate) + vulnerability scanningKnown CVEs lingering for months
SBOM (CycloneDX / SPDX) generated in CIAnswering "are we affected?" in minutes (Log4Shell)

Key takeaways

  • 01Every dependency is code you run, often at install time.
  • 02Lockfiles, npm ci and restricted install scripts block most attacks.
  • 03Review new packages and updates before they reach main.
  • 04An SBOM tells you instantly where a vulnerable component lives.

Check your understanding

1 of 3

When can a malicious npm package run code?

Related concepts