---
title: "Dependency prefixes are a supply chain risk: let's fix them"
description: "SemVer range prefixes like ^, ~ and wildcards in package.json act as a trust policy that lets compromised or hijacked packages flow into CI and production on the next install."
url: "https://swe.quest/articles/dependency-prefixes-are-a-supply-chain-risk-let-s-fix-them-9228bb37d2c90199"
canonical: "https://sourcegraph.com/blog/dependency-prefix-supply-chain-risk"
source: "Sourcegraph"
published: "2026-05-22"
difficulty: "medium"
kind: "How-to"
reading_minutes: 5
tags: ["supply-chain-security","javascript","build-systems","refactoring"]
---

# Dependency prefixes are a supply chain risk: let's fix them

A post on [Sourcegraph](https://swe.quest/sources/sourcegraph.md), published 2026-05-22, 5 min read, How-to. Original: [https://sourcegraph.com/blog/dependency-prefix-supply-chain-risk](https://sourcegraph.com/blog/dependency-prefix-supply-chain-risk)

## Summary

SemVer range prefixes like ^, ~ and wildcards in package.json act as a trust policy that lets compromised or hijacked packages flow into CI and production on the next install. The recommended controls are to commit lockfiles and install with npm ci, pnpm --frozen-lockfile or yarn --immutable, pin exact versions for high-blast-radius packages such as build tools, auth libraries and native-binding deps, set save-exact defaults, disable install scripts with an allowlist for exceptions, and run audits against the locked tree. To roll this out across hundreds of repositories, a Sourcegraph Batch Changes spec with a Node script rewrites React dependency ranges to approved exact versions and refreshes lockfiles without running scripts.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Supply chain security](https://swe.quest/tags/supply-chain-security.md) (Security)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)

## Prerequisites

- npm package management ([easy posts on Engineering management](https://swe.quest/tags/engineering-management.md?difficulty=easy))
- semantic versioning
- lockfiles

## Keywords

npm, pnpm, Yarn, Sourcegraph Batch Changes, package-lock.json, npm ci, React

## Related posts

- [Defending Your Software Supply Chain: What Every Engineering Team Should Do Now](https://swe.quest/articles/defending-your-software-supply-chain-what-every-engineering-team-should-do-now-434c4d75b0885a00.md): Docker · 2026-04-02 · Medium · 9 min read · Supply chain security, CI/CD, Containers, AI agents
  Recent supply chain compromises (the axios npm hijack attributed to Lazarus Group, the TeamPCP campaign via Trivy's GitHub Action, Shai-Hulud, GlassWorm) share one root cause: implicit trust in mutable tags, broad long-lived tokens and unsandboxed runners.
- [Protecting your Supabase projects from npm supply chain attacks](https://swe.quest/articles/protecting-your-supabase-projects-from-npm-supply-chain-attacks-fac18687d5c6f3f1.md): Supabase · 2026-05-26 · Medium · 8 min read · Supply chain security, JavaScript, CI/CD, AI for coding
  npm supply chain attacks reach Supabase users through three common paths: maintainer compromise, typosquatting (including a real \`supabase-javascript\` package and AI-hallucinated names), and build pipeline compromise like the TanStack attack via \`pull\_request\_target\` and a poisoned Actions cache.
- [Securing Python projects from supply-chain attacks](https://swe.quest/articles/securing-python-projects-from-supply-chain-attacks-9ecc242dbcff9bf0.md): Astral · 2026-11-23 · Medium · 7 min read · Supply chain security, Python, CI/CD, Build systems
  Hash-pinning is the core defense against compromised maintainer accounts or hacked distribution servers, because version pins alone fail when PyPI files can be added post-release and GitHub Action tags can be force-pushed.
- [Vendoring](https://swe.quest/articles/vendoring-601ecb035f28a83c.md): htmx essays · 2025-01-27 · Easy · 7 min read · Supply chain security, Build systems, JavaScript, Open source
  Vendoring, copying a dependency's source directly into your repository, gives full dependency visibility, debuggability, auditable code and builds that don't resolve packages at deploy time.
- [Open source security at Astral](https://swe.quest/articles/open-source-security-at-astral-4e24d0de3a4c872a.md): Astral · 2026-04-08 · Medium · 14 min read · Supply chain security, CI/CD, Security, Open source
  Astral secures Ruff, uv and ty against supply chain attacks with layered controls across CI/CD, repository settings, releases and dependencies.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
