Repository navigation
fix(deps): upgrade zod to 4.6.7 (AA-152793) - #159
Merged
logrady merged 1 commit intoNov 24, 2026
Merged
Conversation
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>
AmritpalChera
approved these changes
Nov 24, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:optionalDependenciespin:zod3.25.76 → 4.6.7pnpm.overridesentry:"zod": ">=4.6.6 <5.0.0"No source changes.
src/mcp/server.tsis the only zod consumer and usesz.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.76remained inpnpm-lock.yaml, pulled in via@mistralai/mistralai,@anthropic-ai/sdkand@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:
@mistralai/mistralai@1.15.1^3.25.0 || ^4.0.0@anthropic-ai/sdk@0.79.0^3.25.0 || ^4.0.0@modelcontextprotocol/sdk@1.32.1^3.25 || ^4.0zod-to-json-schema@3.25.1^3.25 || ^4pnpm why zodnow reports a single version, and there are zerozod@3entries left in the lockfile.Verification
All run against the final state of this branch:
test:typescript,build,lint,check:generated— passtest:coverage— 202 files, 3269 passed, 3 skipped4.104.0,5.23.2,6.33.0) — build, type check and full suite pass in every cellpnpm audit— no remaining zod advisoriesKnown warning
openai 4.x and 5.x still pin
zod: ^3.23.8, so installs emitunmet peer zod@^3.23.8: found 4.6.7. This is a warning only —.npmrcis empty, pnpm 10 defaultsstrict-peer-dependenciesto false, and zod is an optional peer of openai. All three matrix cells pass. openai widened to^3.25 || ^4in 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 ofzod-to-json-schema). I capturedtools/listfrom the built server on bothmainand this branch and diffed the output.One semantic difference:
"additionalProperties": falseis no longer emitted — 8 occurrences onmain, 0 here. Every other difference was key ordering. Required arrays, types, descriptions,maxLengthandmaxItemsare all unchanged across all 9 tools.Runtime behavior is identical. Calling a tool with an unknown argument behaves the same on both versions:
additionalProperties: falsemain(zod 3)mainwas 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(...)toregisterToolinstead of a raw shape insrc/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