Track 09 · Lesson 6 of 9Shipping safely

Track 09 · Shipping safely

Dependencies and advisories

Lesson 6 of 9· 7 min

Most of the code you ship, you didn’t write. When a bug is found in a package, an advisory goes public with the affected and fixed versions, and attackers start scanning for sites that haven’t upgraded.

Clear the audit

Bump, override, rerun until no High is left

Illustrative advisories: real-looking, but made up for this lab.

package.json

{
  "dependencies": {
    "next": "15.5.26",
    "axios": "^1.7.4"
  },
  "devDependencies": {
    "vitest": "^2.0.0"
  }
}

$ pnpm why sharp

next 15.5.26
└── sharp 0.34.1

Reading the versions#

Versions read MAJOR.MINOR.PATCH. Security fixes usually land as patch releases (15.5.26 → 15.5.28): the cheapest upgrades you’ll ever make. The lockfile records the exact version of every package actually installed, so CI builds the same bytes you tested; commit it, and install with --frozen-lockfile.

Transitive dependencies#

You never installed sharp or form-data; your framework and HTTP client did. You still ship them. pnpm why <package> shows who pulls one in. If the parent hasn’t released a fix, force the version with an override, and remove the override once the parent catches up.

The race after disclosure#

The patch itself shows attackers where the bug was. The time between an advisory and your upgrade is when the attacks happen, so run the audit in CI where new Highs fail the build.

From advisory to patch

Slow, then fast

From advisory to patch

Researcher

Maintainers

Advisory DB

CVE / GHSA

Your repo

CI

Attacker

Step 1 of 6 · Researcher → Maintainers

Private report

CVE, GHSA and security advisories:
When a vulnerability is found in a package it gets a public advisory. CVE IDs are the global catalogue; GHSA IDs (like GHSA-2464-fhr4-w9xw) are GitHub's advisory database, which pnpm audit reads. Each lists affected versions, the fixed version and a severity.
Semantic versioning and version bumps:
Versions read MAJOR.MINOR.PATCH (15.5.28). PATCH fixes bugs, MINOR adds features compatibly, MAJOR may break things. Security fixes usually land as patch releases, so the bump is small and safe.
Lockfile (pnpm-lock.yaml):
package.json says which versions are acceptable (often a range). The lockfile records the exact version of every package, direct and indirect, actually installed, so every machine and CI build gets the same bytes.
pnpm overrides:
A setting in package.json (pnpm.overrides) that forces a transitive dependency to a version you choose, everywhere in the tree, without waiting for the parent package to update.
pnpm audit --prod:
Compares the lockfile against the advisory database and lists every known vulnerable package. --prod skips devDependencies (test and build tools that never ship). The plan's rule: rerun until no high remains.

In a code review

CriticalFrontend / Backend

Known-vulnerable dependency

Fix: Bump to the fixed version; force transitive ones with an override or resolution; rerun the audit until no High remains; automate it in CI.

0 of 3 checked

Check yourself

A vulnerable package is pulled in by your framework, which hasn’t released a fix. What do you do?