VYPR
Moderate severityNVD Advisory· Published Sep 28, 2023· Updated Dec 3, 2025

Zod 3.22.2 - Regular expression Denial of Service

CVE-2023-4316

Description

Zod in versions 3.21.0 up to and including 3.22.3 allows an attacker to perform a denial of service while validating emails.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
zodnpm
< 3.22.33.22.3

Affected products

1

Patches

1
2ba00fe2377f

[2609] fix ReDoS vulnerability in email regex (#2824)

https://github.com/colinhacks/zodMacs DickinsonOct 3, 2023via ghsa
5 files changed · +5 3
  • deno/lib/README.md+1 1 modified
    @@ -1879,7 +1879,7 @@ You can create a Zod schema for any TypeScript type by using `z.custom()`. This
     
     ```ts
     const px = z.custom<`${number}px`>((val) => {
    -  return /^\d+px$/.test(val as string);
    +  return typeof val === "string" ? /^\d+px$/.test(val) : false;
     });
     
     type px = z.infer<typeof px>; // `${number}px`
    
  • deno/lib/__tests__/string.test.ts+1 0 modified
    @@ -146,6 +146,7 @@ test("email validations", () => {
         `gbacher0@[IPv6:bc37:4d3f:5048:2e26:37cc:248e:df8e:2f7f:af]`,
         `invalid@[IPv6:5348:4ed3:5d38:67fb:e9b:acd2:c13:192.168.256.1]`,
         `test@.com`,
    +    `aaaaaaaaaaaaaaalongemailthatcausesregexDoSvulnerability@test.c`
       ];
       const emailSchema = z.string().email();
     
    
  • deno/lib/types.ts+1 1 modified
    @@ -565,7 +565,7 @@ const uuidRegex =
     // const emailRegex =
     //   /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
     const emailRegex =
    -  /^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
    +  /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
     // const emailRegex =
     //   /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
     
    
  • src/__tests__/string.test.ts+1 0 modified
    @@ -145,6 +145,7 @@ test("email validations", () => {
         `gbacher0@[IPv6:bc37:4d3f:5048:2e26:37cc:248e:df8e:2f7f:af]`,
         `invalid@[IPv6:5348:4ed3:5d38:67fb:e9b:acd2:c13:192.168.256.1]`,
         `test@.com`,
    +    `aaaaaaaaaaaaaaalongemailthatcausesregexDoSvulnerability@test.c`
       ];
       const emailSchema = z.string().email();
     
    
  • src/types.ts+1 1 modified
    @@ -565,7 +565,7 @@ const uuidRegex =
     // const emailRegex =
     //   /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
     const emailRegex =
    -  /^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
    +  /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
     // const emailRegex =
     //   /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
     
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

8

News mentions

0

No linked articles in our index yet.