Skip to content

Track and triage CodeQL dependency vulnerabilities (2) - #126

Merged
jesusmpc merged 3 commits into
mainfrom
bugfix/GH-125-track-and-triage-codeq
Sep 7, 2026
Merged

Track and triage CodeQL dependency vulnerabilities (2)#126
jesusmpc merged 3 commits into
mainfrom
bugfix/GH-125-track-and-triage-codeq

Conversation

@jesusmpc

@jesusmpc jesusmpc commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Closes #125

…atch

Closes the two remaining high-severity image-size DoS advisories
(GHSA-w3rx-r6r6-pgpr, GHSA-5p2g-fcmc-qvqq) by removing the dependency's
usage entirely rather than working around it - no upstream fix exists
for 2.0.2.

- Replaced the 5 imageSize(buffer) call sites (postUploadImage v2
  controller, and the grayscale/flip/negate/remove-background job
  handlers) with sharp(buffer).metadata(), which is already a direct
  dependency and already used by 3 of these same files for the actual
  pixel transform. This also moves dimension reading off the
  synchronous main-thread parse path onto sharp's libuv thread pool,
  and incidentally fixes a latent unhandled-promise-rejection in
  postUploadImage.ts where the dimensions call ran before the
  try/catch and before the file-existence check.
- Removed image-size from code/package.json.
- Bumped the exact-pinned @mastra/memory 1.19.0 -> 1.28.2: this
  project's live conversation-memory backend (wired up in
  connectors.ts) turned out to carry its own transitive image-size
  dependency with the same synchronous imageSize(buffer) call on AI
  chat image attachments - a reachable path the 5 direct call sites
  above didn't cover. 1.28.2 drops image-size in favour of the
  already timeout-guarded probe-image-size.
- Bumped the exact-pinned @mastra/core 1.36.0 -> 1.64.0: required by
  the @mastra/memory bump above, which imports
  MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH from @mastra/core/storage - an
  export that only exists from @mastra/core@1.63.1 onwards. The old
  1.36.0 pin satisfied @mastra/memory's peer range
  (>=1.4.1-0 <2.0.0-0) semver-wise but not its actual runtime API
  surface, which surfaced as a hard crash on `npm run start`
  (SyntaxError: the requested module does not provide an export
  named 'MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH'). Verified all ~40
  named imports @mastra/memory@1.28.2 pulls from every @mastra/core/*
  subpath it uses are present at 1.64.0, not just the one that
  happened to surface first. Bonus: this also resolves a pre-existing
  peer conflict (mastra@1.27.3 requires @mastra/core >=1.50.0, which
  1.36.0 already violated) and pulls a fixed @ai-sdk/provider-utils
  chain, closing the one remaining tracked-as-accepted-risk alert.
- Verified image-size has zero occurrences left in the lockfile by
  exact package name, and npm audit now reports 0 vulnerabilities.

Also added limits.fileSize (100mb) to both multer() instances (v1 and
v2 routers), which previously accepted uploads of unbounded size.
Scoped to size only, not mimetype, since both instances are shared by
image *and* video upload routes.

Verified via a full clean `npm run verify` (matching the CI/Dockerfile
install path), lint, build, and an actual `npm run start` reaching
"Server started" with /v1/liveness and /v1/readiness both returning
200 OK.

Signed-off-by: Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>
@jesusmpc jesusmpc self-assigned this Sep 7, 2026
@jesusmpc jesusmpc added the bug Something isn't working label Sep 7, 2026
@jesusmpc
jesusmpc marked this pull request as ready for review September 7, 2026 12:26
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

@jesusmpc
jesusmpc merged commit ff5196f into main Sep 7, 2026
11 checks passed
@jesusmpc
jesusmpc deployed to azure-develop September 7, 2026 12:27 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Track and triage CodeQL dependency vulnerabilities (2)

1 participant