Find the risk hiding in your project's dependencies
Almost every project you build stands on other people's code: the packages you install, and the packages those packages install in turn. Any one of them can carry a published, known security flaw, or be a hostile lookalike of a package you meant to install. In this mission you build two small projects on your own machine, one npm and one Python, each with deliberately old, vulnerable dependencies. You run real audits (npm audit and pip-audit), read the advisory ids and severities they return, then upgrade and pin and watch the same audit come back clean. You learn what a lockfile is and why it matters, how to inspect a package before you install it, and how to spot a typosquat before it bites. Everything runs against your own projects. It is defensive supply-chain work, and it pairs with Read a CVE and reproduce it, which goes deep on a single flaw.
- Node.js and npm, and Python 3 with uv. The Level 0 lesson Install anything from GitHub covers getting Node and a terminal set up if they are new to you; uv is a fast Python environment manager that this mission installs in one line if you do not have it. No admin rights are needed for uv
- A terminal. On Windows that is PowerShell, already on your PC; on macOS or Linux your normal terminal. Every command here works the same in all three
- An internet connection, so the package managers can fetch packages and the audit tools can reach the advisory databases. No GPU, no Docker, no paid account
- The lab-only mindset the track is built on: you audit and patch projects you own or are responsible for. The companion lesson Read a CVE and reproduce it takes one of these flaws apart in depth and is a natural next step
Why dependencies are the soft underbelly
Understand what you are really installing when you run npm install or pip install, and why that inherited code is where most real-world risk now lives, before you audit anything.
When you run
npm installorpip install, you are pulling in code other people wrote and running it as part of your project. Each package you ask for is a dependency. But almost none of them stand alone: the package you wanted has its own dependencies, and those have theirs, down several layers. Those deeper ones, the packages you never named but that got installed anyway because something you did name needs them, are your transitive dependencies. A small project that lists three packages can easily end up with a hundred on disk.That is the whole point of a package ecosystem, and also its risk. You did not write any of that code, you rarely read it, and yet it runs with the same access your own code has. If one package in that tree has a security flaw, or is replaced by a hostile version, the weakness is now yours, whether or not you ever knew the package was there. This is supply-chain security: the chain of trust that runs from your project through every package it depends on, direct or transitive, and every author and build server behind them.
The flaws come in two shapes, and this mission covers both. The first is a known vulnerability: a published, catalogued flaw in a specific version of a real, legitimate package, the kind an audit tool can look up. Each one usually has a CVE id (Common Vulnerabilities and Exposures, a global free catalogue, with ids like CVE-2023-32681) and often an ecosystem-specific advisory id too: a GHSA id for the GitHub advisory, or a PYSEC id for the Python one. An audit tool reads the exact versions you have installed and tells you which carry a known advisory and which version fixes it.
The second shape is a malicious package: code that is harmful on purpose. The most common delivery is a typosquat, a package with a name one keystroke away from a popular one, hoping you mistype or copy a bad instruction. A related trick is dependency confusion, where an attacker publishes a public package with the same name as one of your company's private internal packages, betting your installer will prefer the public one. Step 5 and step 6 are about spotting both before anything runs.
There is one more fact worth knowing up front, because it is why a bad package is so dangerous: installing a package can run code. npm packages may define
postinstalland similar scripts that execute automatically the moment you install them, before you have run a single line of your own code. So "I only installed it, I never used it" is not the safety people assume. Step 6 shows how to turn that off.TipAuditing your own projects needs no special permission: the code is yours to inspect. The one rule the track is built on still holds in spirit. You scan and patch systems you own or are responsible for, which here means your own projects and the packages they pull in.