Fixing vulnerabilities in packages you never installed
Most security alerts on our dashboard were for packages nobody on the team had added. How transitive dependencies get flagged, and the right and wrong ways to force a fix.
In October 2025 our merchant dashboard got a “critical” alert for form-data. Nobody had installed form-data. It came in underneath axios, the HTTP client, which depends on it. That’s the usual shape of a security alert in a JavaScript app: the problem is three levels down, in something you’ve never imported.
The bug
CVE-2025-7783: form-data built the boundary string that separates parts of a multipart request using Math.random(), which is predictable. If an attacker could see a few other Math.random() values from the same app, and controlled one field of a request, they could guess the boundary and inject extra fields. Fixed in 4.0.4 (and 3.0.4, 2.5.4). Scores ranged from medium to critical depending on who rated it, which is a lesson of its own.
How I fixed it, and how I’d fix it now
The fix that went in was to add form-data at ^4.0.4 to our own package.json. That works: npm then installs a safe version at the top of the tree, and axios uses it.
But it’s a blunt tool. It makes form-data look like something our code uses directly. Nobody can tell, a year later, whether it’s safe to remove. And it only fixes the copy at the top. A package that needs its own nested copy still gets the old one.
The better tool is overrides in package.json. It says “wherever this package appears in the tree, use this version”, without pretending you depend on it. In July 2026 we used overrides for sharp and brace-expansion during another round of fixes, alongside a Next.js and postcss bump:
"overrides": {
"brace-expansion": "^2.0.2",
"sharp": "^0.34.0"
}
(Versions here are illustrative.)
What I learned
- Find the path first.
npm ls form-datashows which of your dependencies pulls it in. Often the cleanest fix is upgrading that parent, which already depends on the patched version. - Use overrides for transitive fixes, not fake direct dependencies. And leave a comment or ticket next to each override saying why it’s there, so someone can remove it when the parent catches up.
- Severity scores aren’t facts about your app. The same bug was rated anywhere from medium to critical. Whether it’s critical for you depends on whether the vulnerable code path is reachable.
- Then patch anyway. Working out reachability for every alert costs more than most bumps. Fix the cheap ones fast and save the careful analysis for the ones that are hard to upgrade.