Skip to main content
Vulnerability Database/CVE-2023-54404

CVE-2023-54404: Zod Library DOS Vulnerability

CVE-2023-54404 is a denial of service flaw in Zod schema-validation library that allows attackers to exhaust memory through unconstrained arrays. This post explains its technical details, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2023-54404 Overview

CVE-2023-54404 is an uncontrolled resource consumption vulnerability [CWE-770] in the Zod schema-validation library through version 4.6.5. Applications that validate incoming arrays with a Zod array schema lacking a length constraint can be forced to exhaust process memory. An attacker submits a large array, and Zod's handleArrayResult logic in $ZodArray accumulates a validation issue object for every failing element without any cap or early termination. The resulting allocation pressure crashes the Node.js process with an out-of-memory condition, producing a denial-of-service outcome against any service that uses Zod to validate untrusted input.

Critical Impact

Remote, unauthenticated attackers can crash applications that validate untrusted arrays with Zod schemas missing explicit length limits, resulting in service outage.

Affected Products

  • Zod schema-validation library versions through 4.6.5
  • Node.js applications and APIs that validate untrusted input with z.array() schemas without .max() or .length() constraints
  • Downstream frameworks and libraries (tRPC, Astro, SvelteKit integrations, and similar) that embed Zod for request validation

Discovery Timeline

  • 2026-10-01 - CVE-2023-54404 published to NVD
  • 2026-10-06 - Last updated in NVD database

Technical Details for CVE-2023-54404

Vulnerability Analysis

Zod is a widely deployed TypeScript-first schema declaration and validation library used to validate HTTP request bodies, query parameters, and other untrusted input. The flaw lives in the array validation path, specifically the handleArrayResult routine inside $ZodArray. When Zod validates an array, it iterates every element against the inner schema and collects a validation issue for each failure. The implementation records all issues before returning control to the caller.

If a developer declares an array schema without a maximum length, Zod will loyally process however many elements the client sends. For a payload containing millions of elements that each fail validation, Zod allocates millions of issue objects. The result is heap exhaustion and process termination. The vulnerability is a classic resource-consumption pattern where the input size directly controls the allocation volume of the validator.

Root Cause

The root cause is missing bounded iteration in $ZodArray. The parser does not apply an implicit upper bound on element count, and it does not short-circuit after a threshold of accumulated issues. Length constraints are opt-in rather than default, so any schema written as z.array(z.string()) without additional modifiers inherits unbounded behavior. The issue is tracked publicly in the project's issue tracker and resolved via a dedicated pull request.

Attack Vector

An unauthenticated remote attacker sends a crafted JSON payload to any HTTP endpoint whose handler validates an array field using a Zod schema that lacks a length cap. The payload contains a very large array of elements that will fail element-level validation, such as numbers where strings are expected. The server-side parser enters the vulnerable loop, accumulates per-element issues, and the Node.js process crashes once V8 reaches its heap limit. Repeated requests sustain the denial of service. See the VulnCheck advisory and GitHub Issue #1872 for additional detail.

Detection Methods for CVE-2023-54404

Indicators of Compromise

  • Node.js process exits with FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory correlated to inbound HTTP requests.
  • Application logs showing spikes in request body size, particularly JSON arrays containing tens of thousands or more elements.
  • Repeated 5xx responses or dropped connections from endpoints that accept array inputs, followed by container or process restarts.

Detection Strategies

  • Inventory all Zod schemas in the codebase and flag any z.array(...) usage that does not chain .max(), .length(), or .nonempty() with an explicit upper bound.
  • Instrument the HTTP layer to record request body size and element counts for array fields, alerting when values exceed expected business thresholds.
  • Add runtime memory monitoring on Node.js workers and alert on sudden heap growth that correlates with validation workloads.

Monitoring Recommendations

  • Enable process-level resource telemetry (RSS, heap used, event loop lag) and forward it to a centralized data lake for correlation with request logs.
  • Monitor API gateway and reverse proxy logs for anomalously large payloads directed at validation endpoints.
  • Track dependency inventories so that any upgrade or downgrade of the zod package is reviewed against this advisory.

How to Mitigate CVE-2023-54404

Immediate Actions Required

  • Upgrade zod to a fixed release that includes the patch merged in GitHub Pull Request #6475.
  • Audit every z.array(...) schema used on untrusted input paths and add an explicit .max(n) constraint sized to the business requirement.
  • Enforce a request body size limit at the HTTP server, reverse proxy, or API gateway layer to reject oversized payloads before they reach Zod.

Patch Information

The maintainers addressed the issue in the Zod repository through Pull Request #6475, referenced from Issue #1872. Consult the VulnCheck advisory for the specific fixed version range and confirm the installed version with npm ls zod or pnpm why zod across all services.

Workarounds

  • Add explicit length constraints to every array schema, for example z.array(z.string()).max(1000), before validation runs.
  • Place a body-size limit on the web framework such as express.json({ limit: '100kb' }) or the equivalent in Fastify, Koa, Next.js, or Hono.
  • Deploy a Web Application Firewall rule that rejects JSON bodies exceeding an element count threshold on affected endpoints until the library is upgraded.
bash
# Configuration example
npm install zod@latest
npm ls zod

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.