CVE-2023-54404: Zod can exhaust memory while validating oversized constrained collections
High CVSS 7.5
- OSV id
- GHSA-mrhx-c7xc-m3w5
- Also known as
- CVE-2023-54404
- Published
- Last modified
Affected packages
| Package | Affected versions | Fixed in |
|---|---|---|
| zod npm |
< 4.6.6 | 4.6.6 |
Versions we track that it affects: zod 3.25.76
How to fix it
Upgrade zod to 4.6.6 or later.
npm install zod@4.6.6
# if it is an indirect dependency: npm update zod (or npm audit fix)
- If it is an indirect dependency, upgrade the package that depends on it, or force the version with "overrides" (npm), "resolutions" (Yarn) or "pnpm.overrides" (pnpm) in package.json.
- Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.
Not sure whether your project uses an affected version? Check your lockfile below for free.
Details
Zod schema-validation library through 4.6.5 contains an uncontrolled resource consumption vulnerability that allows attackers to exhaust memory by submitting a large array to an application using an array schema without a length constraint. Attackers can exploit the handleArrayResult parse logic in $ZodArray, which accumulates every validation issue for each failing element with no cap or early termination, causing the process to allocate excessive issue objects and crash due to out-of-memory conditions.
References
- GHSA-mrhx-c7xc-m3w5 on OSV.dev
- Advisory: https://nvd.nist.gov/vuln/detail/CVE-2023-54404
- Web: https://github.com/colinhacks/zod/issues/1872
- Web: https://github.com/colinhacks/zod/pull/6475
- Web: https://github.com/colinhacks/zod/pull/6652
- Web: https://github.com/colinhacks/zod/commit/a0ebf970f2d752e5f58527cd2942ff48be4f46bd
- Package: https://github.com/colinhacks/zod
- Web: https://www.vulncheck.com/advisories/zod-uncontrolled-resource-consumption-via-array-validation
Am I affected?
Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.
About this data
Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.