← Harden & defendaudit your dependencies before attackers do

audit your dependencies before attackers do

$npm audit --omit=dev

most of your code isn't yours

here's the uncomfortable math on modern software: the average app pulls in hundreds, sometimes thousands, of third-party packages just to do normal stuff like parse a date or format a string. you wrote maybe 10% of what's actually running. the other 90% is dependencies, and dependencies of dependencies, going down a hole nobody fully maps out.

attackers know this. they don't need to find a bug in your code when there's a known, documented, publicly indexed vulnerability sitting in some logging library three layers deep in your node_modules folder. so let's check it like it isn't yours, because it isn't.

npm audit, broken down

if you're running a node or javascript project, this is step one:

npm audit --omit=dev

here's what's actually happening when you run that. npm compares every package in your dependency tree against a database of known vulnerabilities (cves, basically a public registry of "this version of this package has a documented security hole"). it then ranks what it finds by severity: low, moderate, high, critical.

the --omit=dev flag tells it to skip devDependencies, the stuff you use for testing and building but doesn't ship in production. this matters because a vuln in your test runner isn't the same emergency as a vuln in a package that's live, facing the internet, handling user data. scoping the audit to what's actually in production keeps your results relevant instead of noisy.

fixing what's safe to fix

npm audit fix

this command looks at the vulnerabilities it found and automatically upgrades any package where the fix is a non-breaking version bump. it won't force major version jumps that might break your app, it sticks to safe patches. this is the "easy wins" pass. run it, see what it cleans up, then manually review anything left over that needs a bigger upgrade or a dependency swap.

a quick gut check: don't blindly trust auto-fix on a production deploy without testing first. it's safe in the sense that it won't rewrite your logic, but a version bump can still change behavior. run it in a branch, test, then merge.

python projects: pip-audit

if you're in the python world, npm obviously isn't your tool, but the equivalent exists and works the same way conceptually:

pip-audit -r requirements.txt

this scans every package pinned in your requirements file against known vulnerability databases and reports back what's exposed. install it with pip install pip-audit if you don't have it yet. same idea as npm audit: it's not guessing, it's checking your exact dependency list against documented, real-world vulnerabilities.

make it automatic: put it in ci

running these commands once, manually, on a random tuesday is fine but it's not a security practice, it's a one-time glance. dependencies change constantly, new vulnerabilities get disclosed every week, and a package that was clean last month might not be clean today.

the real fix is wiring this into your ci pipeline so it runs on every build, automatically, no one has to remember. the key move is failing the build when something high or critical shows up:

npm audit --omit=dev --audit-level=high

that --audit-level=high flag tells npm to exit with an error code if anything high or critical is found, which most ci systems read as "fail this build." that's the point. you don't want a vulnerable package quietly merging into main because nobody was watching. you want the pipeline to physically stop and make someone deal with it.

same logic applies to pip-audit in a python ci job, just wire the exit code into your build gate the same way.

the takeaway

you don't have to personally audit every library you've ever installed, nobody has time for that. what you do have to do is make checking a habit instead of a hope. run npm audit --omit=dev or pip-audit -r requirements.txt locally right now and see what you're sitting on. then go put the same check into your ci pipeline so it runs every single time code ships, with a fail condition on high and critical findings. that's the whole defense: catch the known stuff before it becomes someone else's way in. send this to whoever owns your package.json, they'll want to know.

watch the reel ↗
the weekly drop

one command a week that makes you harder to hack.

a single tool, explained in plain english, every week. straight to your inbox.

no spam. one email a week. unsubscribe anytime.