Skip to content

Nine npm advisories in a small NestJS app: the copies you never asked for

Clearing a scanner list in nestjs-multer-gridfs took a NestJS major bump, an npm override for a multer copy that Nest pinned, and a test that reads every copy in the lockfile.

Contents

nestjs-multer-gridfs is the small NestJS file service from the post on GridFS uploads. A dependency scanner flagged nine of its packages: lodash, mongoose, proxy-addr, body-parser, multer, path-to-regexp, qs, @nestjs/core and @nestjs/common. PR #1 cleared all nine and merged on 5 Nov 2026. It changed no file under src/ except two new test files.

Two of the vulnerable copies sat in nested node_modules folders, where a top-level check does not look. The upgrade would have added a third.

No fix on the 10.x line

The app ran NestJS 10.4.15 on express 4.21.2. The @nestjs/core advisory, GHSA-36xv-jgw5-4q75, is an injection bug in server-sent events. It affects every version up to 11.1.17, and the only fix is 11.1.18. The last 10.x release, 10.4.22, came out in January 2026, three months before the advisory. A patch release was not an option.

The app has no @Sse() route, so the bug could not be reached here. The PR moved to NestJS 11 anyway to clear the finding. NestJS 11 also needs its peers on 11: @nestjs/mongoose 11.0.4, @nestjs/swagger 11.4.7 and @nestjs/testing 11. @nestjs/cli and @nestjs/schematics stayed on 10, since they only build the app.

Express 5 cleared three more

NestJS 11 runs on express 5. That moved three flagged packages with no line of their own in package.json:

Package Before After
body-parser 1.20.3 2.4.0
path-to-regexp (copy inside express) 0.1.12 removed, express 5 uses 8.4.2
qs 6.13.0 6.17.1

The old 0.1.12 copy lived at node_modules/express/node_modules/path-to-regexp. The top-level copy was 3.3.0. A check that read only the top level would have passed it. The three routes, files/upload, files and files/:id, needed no change under the express 5 path syntax.

Nest pinned its own multer

Before the PR the tree held two multer copies. The app’s own was 1.4.5-lts.1. @nestjs/platform-express 10.4.15 kept 1.4.4-lts.1 in its own node_modules. Both fall in the range of the multer crash advisories, for example GHSA-fjgf-rc76-4x9p.

Bumping the app’s multer to 2.5.0 was not enough. @nestjs/platform-express 11.2.8 lists multer as exactly 2.4.0. GHSA-q7qp-rjg7-q26m covers 2.0.0 up to 2.5.0. Multer 2.5.0 came out on 22 Oct. Nest released 11.2.8 at 12:37 UTC on 23 Oct, still on 2.4.0. The advisory went public at 22:08 UTC the same day.

The PR forces one copy with an npm override:

{
  "dependencies": { "multer": "^2.5.0" },
  "overrides": { "multer": "$multer" }
}

$multer tells npm to use the root package.json range for every multer in the tree. The lockfile now has a single copy, node_modules/multer at 2.5.0. Nest caught up later: 11.2.9, released on 9 Nov, pins 2.5.0. The lockfile still holds 11.2.8, so the override stays until the app moves past it.

A test that reads every copy

src/security-deps.spec.ts parses package-lock.json and finds every path that ends in node_modules/<package>. Each copy must be at or above the first patched version of its release line:

// src/security-deps.spec.ts
{
  pkg: 'multer',
  min: '2.5.0',
  advisory: 'GHSA-44fp-w29j-9vj5, GHSA-q7qp-rjg7-q26m',
},
{
  pkg: 'path-to-regexp',
  min: '0.1.13',
  line: '<0.2.0-0',
  advisory: 'GHSA-37ch-88jc-xwx2, GHSA-rhx6-c78j-4q9w, GHSA-9wv6-86v2-598j',
},

Packages that ship fixes on several lines, such as path-to-regexp and mongoose, get one floor per line. For those, a copy on no listed line fails, so a new major has to be checked before it passes. The comparison uses semver.lt, so 4.18.1-beta.0 counts as below a 4.18.1 floor.

Run against the lockfile from before the PR, all nine package checks fail. Against the merged lockfile, the full suite passes: 19 tests in 3 suites.

Two more tests run the real controller on the real express and multer stack, with GridFS mocked out. One sends a multipart body cut off mid-file. On the old dependencies it crashed the process with Unhandled error. (Error: Unexpected end of form ...) from busboy. Now it returns 400. The other sets trust proxy to ::ffff:10.0.0.0/8 and sends X-Forwarded-For: 203.0.113.7. Under proxy-addr 2.0.7 express took that header as the client IP. Under 2.0.8 it does not.

What is still open

When the PR ran, npm audit went from 46 findings to 33. Critical fell from 3 to 1, high from 16 to 10 and moderate from 13 to 8. Low stayed at 14. Most of the 33 left are in dev and build tools, such as @nestjs/cli 10, jest 29 and webpack. Most need a major bump of @nestjs/cli or jest.

npm audit --omit=dev still reports two moderate findings on js-yaml, which @nestjs/swagger 11.4.7 pins. Swagger only writes YAML for /api-yaml and never parses request input. The fix needs @nestjs/swagger 12 or another override, and the PR left it for later.

Lessons

  • When a fix exists only on the next major, the patch-level upgrade path is closed. Check the advisory’s patched versions before you plan the bump.
  • Look for copies in nested node_modules. Here the vulnerable path-to-regexp and the older multer were never top level.
  • A framework can pin an exact version of a dependency it ships. Bumping your own copy leaves theirs in place. An npm override with $name makes them one copy.
  • Test the lockfile, not package.json. A floor per release line fails as soon as a vulnerable copy returns.
  • Note when an override can go. Here that is @nestjs/platform-express 11.2.9, which pins multer 2.5.0.
Phan Minh Dang Khoa
Principal Engineer · AI, IoT and industrial automation.