Skip to content

Upgrade to zod 4 and bound tool input arrays (v1.9.3) - #24

Merged
christophdb merged 1 commit into
mainfrom
fix/zod-4-bounded-inputs
Nov 4, 2026
Merged

christophdb merged 1 commit into
mainfrom
fix/zod-4-bounded-inputs

Conversation

@christophdb

Copy link
Copy Markdown
Member

Summary

Docker Scout reports CVE-2023-54404 (GHSA-mrhx-c7xc-m3w5, high) for zod 3.25.76 in the 1.9.2 image. NVD has since rejected the CVE, but GitHub still lists the advisory with 4.6.6 as the fix, so scanners keep reporting it.

Oversized arrays in tool calls did cost excessive memory in our own tests, so this PR does more than bump the version:

  • zod 3 → 4.6.7. Zod 4 checks .max() before it parses elements.
  • Bounds on the remaining arrays, because the upgrade only helps where a bound is declared: parameters of query_sql and execute_sql (1000), key_columns of upsert_rows (100), options of add_select_options (1000).
  • zod-to-json-schema removed. It doesn't read zod 4 schemas, so getInputSchema now uses z.toJSONSchema with io: 'input'.

Behaviour changes

  • Calls above the new limits now get a validation error.
  • Tool schemas compared with 1.9.2: propertyNames on records, maximum on integer fields, and no additionalProperties: false on nested objects. Required fields are unchanged and pinned by a test.
  • TRUST_PROXY and the optional where of find_rows would have changed silently in the migration. Both keep their behaviour and have tests.

Test plan

  • npm test, typecheck, lint and build pass
  • npm audit --omit=dev reports 0 vulnerabilities
  • Image built locally: zod 4.6.7, 22 tools listed, stays up under --memory=512m with oversized tool calls (mock mode)
  • Scan the image after the merge, as described in CLAUDE.md, and confirm that Scout no longer reports zod
  • Set the release-v1.9.3 tag

🤖 Generated with Claude Code

Zod reports one issue per failing array element, so an unbounded array
in a tool call could exhaust the process memory. Zod 4 checks .max()
before it parses elements, but only where a bound is declared, so the
upgrade needs bounds on the remaining arrays: parameters (1000),
key_columns (100) and options (1000).

zod-to-json-schema does not read zod 4 schemas and is replaced by
z.toJSONSchema with io: 'input', so fields with a default stay optional.
Two silent changes of the migration are kept out and pinned by tests:
TRUST_PROXY would have defaulted to the string 'true', and find_rows
would have required where.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@christophdb
christophdb merged commit 62ffdbf into main Nov 4, 2026
5 checks passed
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.

1 participant