Season 1 Part of Threat of the Week · Episode 05 of 10
View all 10 episodes →
Threat of the Week · Episode 05 · Supply Chain · Typosquatting · Dependency Confusion · MITRE ATT&CK T1195.001 · February 15, 2027 · 10 min read

Software Supply-Chain Attacks: Typosquatting, Dependency Confusion and Self-Spreading Packages

Threat of the Week · Ep 05 Supply Chain Typosquatting Dependency Confusion MITRE ATT&CK T1195.001 · 10 min read
💬 Feedback
35+
Companies reached by dependency confusion
Including Apple, Microsoft and PayPal, in a researcher's authorised 2021 tests
500+
npm packages hit by a self-spreading worm
CISA's September 2025 alert on the worm known as Shai-Hulud
~10 hrs
PyPI sign-ups paused in March 2024
The Python package index halted new users and projects during a malware upload campaign

When developers build an app today, they write only a fraction of the code themselves. The rest comes from open-source packages, downloaded automatically by tools that trust names. If an attacker can get a package with the right name in front of those tools, their code ships inside your software.

A typical web application can depend on hundreds or thousands of open-source packages, most of them pulled in indirectly by other packages. Package managers such as npm for JavaScript and pip for Python fetch them by name, often on every build, often without anyone looking.

That automation is what makes modern development fast. It is also an attack surface. Instead of breaking into a company, an attacker can publish code that the company's own build system will download and run.

In a supply-chain attack, you do not get hacked. You install the attacker's code yourself, on purpose, because the name looked right.
MITRE ATT&CK mapping Technique: T1195.001, Compromise Software Dependencies and Development Tools
Parent: T1195 Supply Chain Compromise
Tactic: Initial Access (TA0001)
MITRE's description includes: malicious or re-registered open-source packages, typosquatted names and compromised CI/CD components. Its examples include the Shai-Hulud worm, which spreads through compromised maintainers' packages.

1. Typosquatting: The Misspelled Package

Typosquatting relies on a simple mistake. A developer means to install a popular package and types the name slightly wrong, or copies a name from a forum post or an AI-generated suggestion. The attacker has already registered that misspelling, or a convincing variation, and filled it with malware.

Because installing a package can run code straight away, the malware does not need anyone to use the package. Installation is enough.

In March 2024, PyPI, the main repository for Python packages, temporarily stopped new user registrations and new project creation for around ten hours to deal with what it called a malware upload campaign. Security researchers reported that the packages imitated popular libraries and carried malware designed to steal cryptocurrency wallets, browser cookies and saved credentials, with persistence to survive reboots.

2. Dependency Confusion: When the Public Name Wins

Large organisations also write their own internal packages, with names such as companyname-auth-utils, stored in a private repository. Dependency confusion abuses the way some build tools decide where to get a package when the same name exists both privately and publicly.

  1. The attacker learns an internal package name. These often leak, for example inside JavaScript files published on a company's website.
  2. They publish a public package with exactly that name, often with a higher version number.
  3. A misconfigured build system checks the public registry, sees the newer version and installs it instead of the internal one.
  4. The attacker's code runs inside the company's build environment.

The technique was demonstrated publicly in February 2021 by security researcher Alex Birsan. With permission from the companies involved, he showed that his test packages were downloaded and run inside more than 35 organisations, including Microsoft, Apple, PayPal, Shopify, Netflix, Tesla and Uber, across the npm, PyPI and RubyGems ecosystems. He found many of the internal package names in public JavaScript files. The companies paid him bug bounties for the findings.

3. Self-Spreading Packages: The 2025 npm Worm

The newest form goes further: compromising the real package, rather than a lookalike.

In September 2025, CISA warned of a widespread compromise of npm, the largest JavaScript package registry. A self-replicating worm, publicly known as Shai-Hulud, had compromised more than 500 packages. According to CISA, it searched infected systems for credentials such as GitHub personal access tokens and cloud API keys, sent them to the attackers and published them to a public GitHub repository. It then used stolen developer credentials to log in to npm, inject itself into other packages that developer maintained, and publish infected versions.

That last step is what made it spread on its own. Every infected developer machine became a way to infect more packages.

Why developer machines matter Developer laptops and build servers often hold the keys to production: cloud credentials, code signing access and publishing tokens. A malicious package that runs there can reach far more than a single computer.

4. How to Prevent It

MITRE's mitigations and CISA's npm guidance overlap heavily. In practice:

  • Pin and lock dependencies. Use lock files (package-lock.json, yarn.lock, poetry.lock and similar) and pin exact versions, so a new, malicious release is not pulled in automatically. MITRE also recommends pinning GitHub Actions to commit hashes.
  • Use an internal, approved package source. MITRE recommends that developers pull packages from internal approved repositories. Configure build tools to fetch internal package names only from the private registry, and reserve those names publicly or use scoped names so nobody else can claim them.
  • Vet new dependencies. Check the exact spelling, the publisher, the download history and the repository before adding anything new. Be particularly careful with package names suggested by AI coding tools.
  • Protect developer and publishing accounts. CISA recommends phishing-resistant MFA on all developer accounts, especially GitHub and npm, and rotating credentials after any suspected compromise.
  • Limit what install scripts can do. Where practical, disable automatic install scripts in CI, and run builds with minimal credentials and restricted network access.
  • Keep an inventory. A software bill of materials (SBOM) makes it possible to answer "are we affected?" within minutes when the next compromised package is announced.

5. How Defenders Can Detect It

MITRE's detection guidance for T1195.001 focuses on what happens during and immediately after installation:

  • Package managers or build tools that spawn shells, download additional tools or run scripts as soon as a package is installed.
  • Outbound connections from build systems to unfamiliar domains or registries that are not on your approved list. In the npm worm case, CISA advised blocking connections to webhook.site domains and reviewing firewall logs.
  • New or changed dependencies appearing in lock files without a matching code review.
  • Unexpected package publishing activity from your organisation's npm or PyPI accounts, and new tokens, GitHub Apps or webhooks you did not create.
When a compromised package is announced Following CISA's npm guidance: search lock files, including nested dependencies, and any cached artifact repositories for the affected versions. Pin to known-safe releases. Rotate every developer, CI and cloud credential that could have been exposed. Remove unnecessary GitHub Apps and OAuth apps, audit webhooks and secrets, and turn on secret scanning and branch protection.

Final Thoughts

Open source is one of the great successes of modern software, and none of this is a reason to stop using it. It is a reason to stop trusting names blindly.

Lock what you install, fetch internal packages only from internal sources, protect the accounts that publish code, and watch what your build systems do. The attacks in this episode all depended on automated systems doing exactly what they were told without anyone checking.

Every dependency is code you have chosen to run. Treat the decision with the same care as code you write yourself.

Sources and Further Reading

Cyber Insight | Threat of the Week · Season 1

Making cybersecurity easier to understand, one issue at a time.

Season 1

Threat of the Week · All 10 Episodes

One attack technique explained, mapped to MITRE ATT&CK, with detection tips.

01
MFA fatigue (push bombing): how it works and how to detect it Episode 01 · Published
02
OAuth consent phishing Episode 02 · Published
03
QR-code phishing (quishing) Episode 03 · Published
04
Adversary-in-the-middle phishing kits and session theft Episode 04 · Published
05
Software supply-chain attacks: typosquatting and dependency confusion Episode 05 · Now reading
06
Business email compromise Episode 06 · Published
07
Infostealer malware and stolen browser sessions Episode 07 · Coming soon
08
Living off the land: attackers using your own tools Episode 08 · Coming soon
09
Deepfake voice and video scams Episode 09 · Coming soon
10
Credential stuffing Episode 10 · Coming soon
PS
Poorna Sujampathi Rathnayaka
Writer · Cyber Insight · Digital Literacy

I started Cyber Insight because everywhere online people only talk about cybersecurity in technical terms — and most people are left without a proper understanding of how the digital world works. I work in cybersecurity, but I write here for everyone. No jargon. Just clear, honest explanations.