Your Dependencies Are Your Attack Surface: Software Supply Chain Security in 2026
Run npm install on a fresh project with a single dependency and look inside node_modules. It is common to find hundreds of packages you never chose, written by maintainers you have never heard of, some of which run code
Run npm install on a fresh project with a single dependency and look inside node_modules. It is common to find hundreds of packages you never chose, written by maintainers you have never heard of, some of which run code on your machine during installation. Every one of those packages is code you are trusting. In 2026 that trust has been tested repeatedly and publicly, and the lesson for every developer is the same: attackers have stopped breaking into applications one by one and started poisoning the things applications are built from.
This article explains how software supply chain attacks work, walks through what happened in the npm and PyPI ecosystems over the past year, and gives a practical, ordered list of defenses a student or junior developer can adopt right away.
What Is a Supply Chain Attack?
A software supply chain attack compromises code, dependencies, or build systems that an organization already trusts, rather than attacking the organization directly. The logic is leverage. Compromising one popular library gives an attacker code execution on the machines of everyone who installs it. Compromising a build pipeline lets an attacker alter software after the developers have written it and before users receive it.
The attack surface is wider than most developers realize:
Package registries: npm, PyPI, crates.io, Maven Central, Docker Hub.
Build and CI systems: GitHub Actions workflows, runners, caches, signing keys.
Developer tooling: editor extensions, CLI tools, security scanners, AI coding assistants and their plugins.
Maintainer accounts: the people (and tokens) with permission to publish.
Notice that a developer's laptop and a CI runner are both rich targets. They hold cloud credentials, SSH keys, API tokens, and publish rights, which is exactly what an attacker wants.
The Common Attack Techniques
Most incidents combine a few recurring patterns.
Typosquatting and lookalike packages. An attacker publishes reqeusts hoping someone mistypes requests. This is the oldest trick and still works, though it is the least sophisticated.
Dependency confusion. If a company uses a private package named internal-utils and an attacker publishes a public package with the same name and a higher version number, a misconfigured build may fetch the public one.
Install scripts. Many ecosystems allow packages to run arbitrary commands at install time (for example, npm's preinstall and postinstall hooks). Malicious packages use them to steal credentials the moment they are installed, before any of your code runs.
Account and token takeover. Phishing a maintainer, stealing a publishing token from a leaked file or compromised machine, or abusing weak multi-factor authentication lets an attacker publish a malicious version of a legitimate, trusted package. This is the most dangerous pattern because the package name, history, and reputation all look normal.
CI/CD abuse. Misconfigured GitHub Actions workflows can be tricked into running attacker-controlled code with access to secrets, or into using a poisoned build cache. Attackers then publish malicious releases through the project's own legitimate pipeline.
Worms. Newer attacks self-propagate. Malware steals the publishing credentials of the developer who installed it, then uses them to infect that developer's own packages, which infect the next victims, and so on.
What Happened: A Year of Incidents
Several events over the past year show how these techniques play out. Details below come from security vendor and community write-ups, so specifics (dates, counts, attribution) may be refined as investigations conclude. Check primary sources before citing any figure.
The Shai-Hulud worm (September 2025). One of the first widely reported self-spreading npm attacks. Malicious code harvested secrets from infected environments and used stolen npm tokens to republish additional compromised packages, turning one compromised maintainer into dozens or hundreds of infected packages. In response, npm announced a major authentication overhaul around the end of 2025. Security researchers noted that this was progress, but did not make npm immune, since phished credentials can still lead to malicious publishes.
A chained campaign in early 2026. Multiple reports describe a financially motivated group, tracked as TeamPCP, running a sustained campaign beginning around late February 2026 with the compromise of a widely used security scanner, Trivy. Stolen credentials from one victim were then used to reach others. Reports link the campaign to a malicious release of LiteLLM, a popular AI-gateway library on PyPI, in late March.
The axios compromise (31 March 2026). Axios, an HTTP client with on the order of 100 million weekly downloads, had malicious versions published to npm after a maintainer account was taken over. Analyses emphasized how deliberately the release avoided classic red flags: it came from a long-established package with a trusted history, not a brand-new lookalike. Because the malicious versions were live for only a short window, the damage depended heavily on whether projects automatically pulled the newest version.
July 2026 npm incidents. Further compromises affected packages including AsyncAPI, reportedly via a GitHub Actions "pwn request" weakness, where a workflow executed untrusted code from a pull request with privileged access. This showed that compromising a project's CI could be as effective as stealing a maintainer's password.
Platform responses. GitHub published a summary in late July 2026 of changes to npm and GitHub Actions aimed at disrupting these techniques. Some reports also say a major npm release now blocks install scripts by default. Because this is the kind of detail that changes quickly, verify the current behavior in the official npm documentation rather than relying on a summary.
The pattern across all of these is that the attacks target trust and automation: trusted maintainers, trusted tools, trusted pipelines, and automatic installs.
Why Developers Are Attractive Targets
Think about what is on a typical developer machine or CI runner: cloud provider credentials, database passwords, .env files, SSH keys, package registry tokens, and browser sessions. Malware that runs during npm install can read all of it. Compromising a developer can also provide a route to compromising every product that developer ships. This is why defenders now say to protect the development environment first.
AI coding tools add a new angle. Agents that install packages, run commands, and use plugins extend the same trust problem. A model that suggests a dependency that does not exist, which an attacker then registers, is sometimes called "slopsquatting." Treat every AI-suggested package name as unverified until you have checked it.
Defenses You Can Apply Today
There is no single fix, so the goal is layered defense: make attacks harder, reduce what they can reach, and notice them sooner. These are ordered roughly from easiest to more involved.
- Use lockfiles and install from them
A lockfile records the exact version (and integrity hash) of every dependency. Installing from the lockfile means a newly published malicious version cannot silently slip in.
bash
Reproducible, lockfile-only install. Fails if package.json and lockfile disagree.
npm ci
Python equivalent: pin with hashes
pip install --require-hashes -r requirements.txt
Go: go.sum records module hashes and is verified automatically
go mod verify
Commit your lockfile. Be wary of blindly running npm install or npm update in CI, since those can change what gets installed.
- Add a cooldown before adopting new versions
Many malicious releases are discovered and removed within hours or days. Delaying adoption of brand-new versions gives the ecosystem time to catch problems. Dependency update tools can often be configured to wait a set period before proposing a new release. Even a simple habit of not upgrading the same day a version appears helps.
- Disable or restrict install scripts
Since install scripts execute automatically, restricting them removes a major attack path.
bash
Skip lifecycle scripts for this install
npm ci --ignore-scripts
Make it the default for a project
npm config set ignore-scripts true
Some packages legitimately need scripts (for example, to compile native code), so you may need to allow-list those individually and rebuild them deliberately.
- Reduce the number of dependencies
Every dependency is a liability as well as a convenience. Before adding a package for something small, consider whether a few lines of your own code would do. Go's culture of a rich standard library and few dependencies is partly a security advantage. A smaller tree means fewer maintainers to trust and fewer places to be compromised.
- Protect your own accounts and tokens
If you publish packages, your account is part of everyone else's supply chain.
Enable multi-factor authentication, preferably with a hardware key or passkey, which resists phishing better than SMS or codes typed into websites.
Prefer short-lived, narrowly scoped tokens over long-lived ones, and never commit them.
Where supported, use "trusted publishing," which lets your CI publish using short-lived identity-based credentials rather than a stored secret.
Review who has publish rights and remove people who no longer need them.
- Harden your CI/CD pipeline
For GitHub Actions in particular:
yaml
Pin third-party actions to a full commit SHA, not a movable tag
- uses: actions/checkout@
Give the workflow the minimum permissions it needs
permissions:
contents: read
Key habits:
Pin actions to commit SHAs. Tags like @v3 can be moved by an attacker who compromises the action's repository.
Use least-privilege permissions. Default the token to read-only and grant more only where needed.
Never run untrusted pull request code with secrets. Be especially careful with the pull_request_target trigger, which runs with elevated privileges and has been behind multiple real-world compromises.
Be careful with caches. Poisoned build caches have been used to inject code into later, trusted builds.
Separate build from publish, so the step with release credentials does not run untrusted code.
- Verify provenance and scan for known problems Audit known vulnerabilities: npm audit, pip-audit, govulncheck, and similar tools flag dependencies with published CVEs. Check signatures and provenance: npm supports provenance attestations showing which source repository and build produced a package, and npm audit signatures verifies registry signatures. Sigstore and SLSA are broader frameworks for signing and attesting builds. Generate an SBOM (software bill of materials): a machine-readable inventory of everything in your software. When a new compromise is announced, an SBOM lets you answer "are we affected?" in minutes rather than days.
- Isolate your development environment
Assume that one day something malicious will run. Limit the blast radius:
Develop inside containers or dev containers where practical, so a compromised package cannot read your whole home directory.
Keep production credentials off your laptop. Use short-lived credentials and separate accounts for development and production.
Use a password manager or credential helper rather than plain-text .env files holding long-lived secrets.
Review browser extensions and editor extensions as carefully as you review packages. They run with significant access too.
- Prepare to respond
Assume you will eventually install something bad. Know in advance how you would respond:
Identify which projects and machines installed the affected version (lockfiles and SBOMs help).
Rotate every credential that could have been exposed: cloud keys, registry tokens, SSH keys, API keys.
Rebuild from a clean environment rather than trying to clean an infected one.
Review logs for unusual activity, such as unexpected publishes or cloud API calls.
Speed matters. In several recent incidents, the malicious versions were available only for hours, so quickly noticing and rotating secrets limited damage.
A Realistic Mindset
It is tempting to react to all this by distrusting everything, but that is not workable. Modern software is built on shared components, and no individual can audit all of them. Security specialists increasingly frame the problem differently: the attack surface is permanent, so the aim is to make compromise less likely, limit what a compromise can reach, and shorten the time to detect and recover.
For a student developer, that translates into a short checklist worth making habitual:
Commit lockfiles and use npm ci (or your ecosystem's equivalent) in CI.
Do not upgrade to a version the day it is published unless you need to.
Restrict install scripts and review new dependencies before adding them.
Use hardware-key or passkey MFA on registry and GitHub accounts.
Pin CI actions to SHAs and keep workflow permissions minimal.
Keep long-lived secrets out of your repo and off your laptop wherever possible.
Double-check any package an AI tool suggests actually exists and is the real one.
Key Takeaways
Supply chain attacks target the trusted components and processes software depends on, giving attackers leverage over many victims at once.
Recent incidents show account takeover, CI/CD abuse, install scripts, and self-spreading worms working in combination, and attackers now deliberately avoid obvious warning signs.
Developer machines and CI runners are high-value targets because they hold credentials and publishing rights.
Defenses are layered: lockfiles, version cooldowns, restricted install scripts, fewer dependencies, strong account security, hardened CI, provenance checks, SBOMs, and isolation.
Having an incident-response plan, especially for rotating credentials, matters as much as prevention.
The uncomfortable truth is that you inherit the security of everything you import. The encouraging truth is that a handful of inexpensive habits, adopted early, remove most of the easy paths attackers rely on. Starting those habits while you are still learning means they will be second nature by the time you are shipping code that other people depend on.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.