Junglewise Threat Intelligence

CVE-2023-4316: Zod email validation regular expression denial of service

CVE-2023-4316 · Severity: low · CVSS 3.1 · Published 2023-09-28

Executive brief

Zod is a popular data validation library for JavaScript/TypeScript applications. The email validation function uses a regular expression vulnerable to ReDoS (Regular Expression Denial of Service), allowing an attacker to cause excessive CPU consumption and application hang by providing a maliciously crafted email string during validation.

Technical details

The vulnerability is a ReDoS (Regular Expression Denial of Service) flaw in the email validation regex pattern. The complex email regex contains nested quantifiers that cause catastrophic backtracking when processing certain input patterns, leading to exponential time complexity. An unauthenticated network attacker can trigger the vulnerability by submitting a specially crafted email string to any application using Zod's z.string().email() validator, causing the validation to hang and consume CPU resources. The vulnerability affects Zod versions up to 3.22.2 and was fixed in version 3.22.3 by replacing the vulnerable regex with a safer implementation.

Affected products

  • Colinhacks Zod up to 3.22.2

Timeline

  • 2023-07-26: disclosed: Issue reported on GitHub
  • 2023-09-28: advisory: GHSA and CVE advisory published
  • 2023-09-28: patched: Fix released in version 3.22.3

References