Heuristic:0sec labs 0 Supply Chain Patch Overrides
| Knowledge Sources | |
|---|---|
| Domains | Tooling, Dependency_Management, Security |
| Last Updated | 2026-10-30 00:00 GMT |
Overview
Force a minimum patched version of a transitive dependency across the entire dependency tree using lockfile overrides, neutralizing supply-chain advisories without waiting for upstream releases.
Description
When a security advisory affects a transitive dependency (one pulled in by another package, not declared directly), you cannot fix it by simply updating your own package.json — the vulnerable version may still be resolved deep in the tree. Overrides (in pnpm and npm) let you force a specific version of a package everywhere it appears, regardless of what upstream packages request. The lockfile records both the override rule and the resulting resolved version with its integrity hash, so CI (--frozen-lockfile) fails if the override is removed or the tree drifts.
This heuristic covers the practical pattern of auditing advisories, adding targeted overrides, and verifying the lockfile reflects the patched version.
Usage
Apply this heuristic when:
- A security advisory names a transitive dependency (e.g., nanoid < 3.3.18, dompurify < 3.4.17, zod affected versions).
- You need a patched version but the upstream package that depends on the vulnerable one has not released an update.
- CI must enforce that the patched version is always resolved, even after adding new dependencies.
The Insight (Rule of Thumb)
- Action: Add an entry to the overrides block in package.json (propagated to pnpm-lock.yaml) forcing the patched version.
- Value: Use a range that includes only patched versions — e.g., nanoid@<3.3.18: 3.3.18 (force exact patched version), dompurify: ^3.4.17 (force minimum), zod: 4.6.6 (pin exact).
- Trade-off: An override may introduce a breaking change in the transitive dependency if the forced version is incompatible with what the upstream package expects. Test after applying.
- Verification: Run pnpm install --frozen-lockfile in CI; the lockfile must contain the overridden resolved version with its integrity hash.
Reasoning
Package managers resolve the dependency tree top-down: each package's specifiers (^1.2.0) are resolved to exact versions from the registry. Without an override, a transitive dependency is resolved to whatever version the requesting package specifies — which may be vulnerable. The override intercepts resolution: when the resolver encounters the overridden package name, it substitutes the forced version regardless of the requesting specifier.
The lockfile proves the override took effect: the packages section shows the resolved version with its sha512 integrity hash, and the overrides block records the rule. If someone removes the override or adds a new dependency that pulls the vulnerable version, --frozen-lockfile fails until the lockfile is regenerated with the override still applied.
In this repository, the overrides block forces patched versions of at least 30 transitive dependencies including nanoid (>= 3.3.18), dompurify (>= 3.4.17), zod (= 4.6.6), undici, esbuild, postcss, and qs — each addressing a specific supply-chain advisory.