Skip to content

fix(deps): upgrade zod to 4.6.7 (AA-152793) - #159

Merged
logrady merged 1 commit into
mainfrom
lenaogrady/aa-152793-supply-chain-amplitude-ai-node-upgrade
Nov 24, 2026
Merged

logrady merged 1 commit into
mainfrom
lenaogrady/aa-152793-supply-chain-amplitude-ai-node-upgrade

Conversation

@logrady

@logrady logrady commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Resolves AA-152793 — Semgrep supply-chain finding 1039774362.

The vulnerability

GHSA-mrhx-c7xc-m3w5 / CVE-2023-54404 (high, CWE-770): "Zod can exhaust memory while validating oversized constrained collections."

The vulnerable range is <4.6.6, so there is no 3.x patch — closing this requires the major bump from 3.25.76 to 4.x.

Changes

Two lines in package.json, plus the regenerated lockfile:

  • Direct optionalDependencies pin: zod 3.25.76 → 4.6.7
  • New pnpm.overrides entry: "zod": ">=4.6.6 <5.0.0"

No source changes. src/mcp/server.ts is the only zod consumer and uses z.string(), z.enum(), z.array(), .optional() and .describe() — all unchanged in zod 4.

Why the override is needed

Bumping the direct dependency alone does not close the finding. After the bump, a second zod@3.25.76 remained in pnpm-lock.yaml, pulled in via @mistralai/mistralai, @anthropic-ai/sdk and @google/genai's MCP SDK. Semgrep scans the lockfile, so that copy would have kept the finding open through a merge.

This was lockfile stickiness rather than a real constraint — every one of those consumers already accepts zod 4:

Package zod range Kind
@mistralai/mistralai@1.15.1 ^3.25.0 || ^4.0.0 direct dependency
@anthropic-ai/sdk@0.79.0 ^3.25.0 || ^4.0.0 optional peer
@modelcontextprotocol/sdk@1.32.1 ^3.25 || ^4.0 peer
zod-to-json-schema@3.25.1 ^3.25 || ^4 peer

pnpm why zod now reports a single version, and there are zero zod@3 entries left in the lockfile.

Verification

All run against the final state of this branch:

  • test:typescript, build, lint, check:generated — pass
  • test:coverage — 202 files, 3269 passed, 3 skipped
  • openai peer-range bookends (4.104.0, 5.23.2, 6.33.0) — build, type check and full suite pass in every cell
  • pnpm audit — no remaining zod advisories

Known warning

openai 4.x and 5.x still pin zod: ^3.23.8, so installs emit unmet peer zod@^3.23.8: found 4.6.7. This is a warning only — .npmrc is empty, pnpm 10 defaults strict-peer-dependencies to false, and zod is an optional peer of openai. All three matrix cells pass. openai widened to ^3.25 || ^4 in v6, so this clears itself whenever the peer range moves past v5.

Behavioral change reviewers should see: MCP tool schemas

The MCP SDK derives tool input schemas differently under zod 4 (zod's native toJSONSchema() instead of zod-to-json-schema). I captured tools/list from the built server on both main and this branch and diffed the output.

One semantic difference: "additionalProperties": false is no longer emitted — 8 occurrences on main, 0 here. Every other difference was key ordering. Required arrays, types, descriptions, maxLength and maxItems are all unchanged across all 9 tools.

Runtime behavior is identical. Calling a tool with an unknown argument behaves the same on both versions:

advertises additionalProperties: false rejects unknown arg?
main (zod 3) yes no — accepts, strips it
this branch (zod 4) no no — accepts, strips it

main was advertising a strictness it never enforced, so the zod 4 schema is arguably the more accurate one. The only practical impact is on an MCP client that validates arguments client-side against the advertised schema: it would no longer reject a typo'd argument locally, though the server ignores it either way.

Flagging it rather than silently changing it. If we'd prefer to preserve the old advertised contract, the fix is passing z.strictObject(...) to registerTool instead of a raw shape in src/mcp/server.ts — but that's a source change beyond this dependency bump, so I've left it out.

Worth noting nothing in CI would have caught this; a schema-snapshot test in test/ would guard it going forward.

🤖 Generated with Claude Code

Resolves GHSA-mrhx-c7xc-m3w5 / CVE-2023-54404 (high): "Zod can exhaust
memory while validating oversized constrained collections" (CWE-770).
Vulnerable range is <4.6.6, so there is no 3.x patch and this requires
the major bump.

Bumps the direct optionalDependency from 3.25.76 to 4.6.7, and adds a
pnpm override so transitive consumers resolve to the same copy. Without
the override, @mistralai/mistralai, @anthropic-ai/sdk and @google/genai's
MCP SDK kept a second zod 3.25.76 in the lockfile, which would have left
the Semgrep finding open. All of those already declare "^3.25 || ^4", so
they resolve to zod 4 without further changes.

No source changes needed: src/mcp/server.ts is the only zod consumer and
uses z.string/enum/array/optional/describe, all unchanged in zod 4.

Verified: tsc, build, lint, check:generated, and 3269 tests pass, across
the openai 4.104.0 / 5.23.2 / 6.33.0 peer-range bookends. pnpm audit
reports no remaining zod advisories and no zod 3 in the lockfile.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@logrady
logrady requested a review from a team as a code owner November 24, 2026 17:55
@linear-code

linear-code Bot commented Nov 24, 2026

Copy link
Copy Markdown

AA-152793

@logrady
logrady merged commit b9da1cb into main Nov 24, 2026
9 checks passed
@logrady logrady mentioned this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants