Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Sourcegraph 5 min read How-to mediumAdept

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

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.

Assumes: npm package managementsemantic versioninglockfiles

Related posts

  • Defending Your Software Supply Chain: What Every Engineering Team Should Do Now

    Docker mediumAdept

    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. The recommended defenses start with pinning Actions to commit SHAs and images to digests, using lock files with npm ci, and applying 3-day cooldowns on new dependency versions, since most malicious releases live only hours. Further layers are short-lived scoped CI credentials, avoiding pull_request_target, artifact proxies and build-time SBOMs, plus canary tokens and credential cleanup on developer machines. AI coding agents should run in microVM sandboxes and MCP servers should be governed. Many recommendations are paired with Docker products such as Hardened Images, Scout, Sandboxes and MCP Gateway.

  • Protecting your Supabase projects from npm supply chain attacks

    Supabase mediumAdept

    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. Malicious lifecycle scripts can exfiltrate env vars, cloud metadata, kubeconfig, npm tokens and SSH keys before `npm install` even returns. The recommended layered defenses are pnpm 11 with a 3–7 day `minimumReleaseAge`, exact version pins for sensitive deps, committed and reviewed lockfiles, disabled install scripts with an allowlist, verifying `@supabase/` scopes, SHA-pinned GitHub Actions, and credential rotation after suspected exposure. A ready-made prompt lets a coding agent apply these settings across pnpm, npm, yarn and bun.

  • Securing Python projects from supply-chain attacks

    Astral mediumAdept

    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. Concrete hardening steps for Python projects on GitHub: pin Actions by commit SHA (via pinact, Dependabot or Renovate), verify SHA-256 hashes of downloaded binaries in Bash, Python or TypeScript, use PyPI Trusted Publishing over OIDC, require approvals on release environments, and lint workflows with zizmor. With uv, add dependency cooldowns via exclude-newer, lock CI tools as dependency groups and run them with UV_LOCKED, lock PEP 723 scripts, and set no-build to avoid executing source-distribution build backends.

  • Vendoring

    htmx essays easyNovice

    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. Its real weakness is the transitive dependency problem, but that friction usefully discourages large dependency graphs. htmx shows the cost of the alternative: 16 declared npm dev dependencies balloon to 411 packages and a 110 MB node_modules, including an unwanted polyfill that threatens IE compatibility. The essay argues for fewer dependencies, vendor-friendly zero-dependency libraries, and vendor-first dependency managers that handle transitive deps, updates and local modifications.

  • Open source security at Astral

    Astral mediumAdept

    Astral secures Ruff, uv and ty against supply chain attacks with layered controls across CI/CD, repository settings, releases and dependencies. In GitHub Actions they ban `pull_request_target` and `workflow_run` org-wide, pin all actions (including nested ones) to verified commit SHAs using zizmor and GitHub policy, default to empty permissions, and isolate secrets in deployment environments. Releases use Trusted Publishing, Sigstore attestations, immutable releases, no caching, two-person approval gates and tag protection rulesets. Privileged automations like commenting on PRs move into a separate GitHub App, and dependency updates go through Renovate/Dependabot with cooldowns.

The quest for software engineering knowledge.

Look:
Layout: