Zod 3.22.2 - Regular expression Denial of Service

7.5

High

Discovered by 

Diana Osorio

Offensive Team, Fluid Attacks

Summary

Full name

Zod 3.22.2 - Regular expression Denial of Service

Code name

State

Public

Release date

Sep 28, 2023

Affected product

Zod

Affected version(s)

Version 3.22.2

Vulnerability name

Asymmetric denial of service - ReDoS

Remotely exploitable

Yes

CVSS v3.1 vector string

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

CVSS v3.1 base score

7.5

Exploit available

Yes

CVE ID(s)

Description

Zod in version 3.22.2 allows an attacker to perform a denial of service while validating emails

Vulnerability

Zod performs validations to determine if a string belongs to a valid email, the validations use of a vulnerable regular expression that allows an attacker to send a malicious string of data to generate excessive processing overhead and ultimately crash the server. It was identified that by sending a string of data of a predetermined length and increasing the number of characters, the time it takes for the application to process the request grows exponentially.

Exploitation

The application uses the following vulnerable regular expression:

^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]

First we create a scheme to validate emails:

export const validateSchema = (schema) => (req, res, next) =>{
 try {
 if(req.query.email){
 schema.parse(req.query)
 }else{
 schema.parse(req.body)
 }
 next()
 } catch (error) {
 return res
 .status(400)
 .json({error: error.errors.map((error) => error.message)})
    }
}


export const pdfGeneratorSchema = z.object({
    email: z.string({
        required_error: "Email is required"
    }).email({message: "Invalid email"})
})

And perform validation:

router.get('/api/customer/export',  validateSchema(pdfGeneratorSchema), authorized, exportData);

Evidence of exploitation

First we send invalid information and we can see that the validation done by Zod works correctly, but when we increase the number of characters in the request for the invalid data, we can see that the processing time increases until the server stops responding.

Our security policy

We have reserved the ID CVE-2023-4316 to refer to this issue from now on. Disclosure policy

System Information

  • Version: Zod 3.22.2

  • Operating System: GNU/Linux

Mitigation

There is currently no patch available for this vulnerability.

References

Timeline

Vulnerability discovered

Sep 18, 2023

Vendor contacted

Sep 19, 2023

Public disclosure

Sep 28, 2023

Start your 21-day free trial

Discover the benefits of our Continuous Hacking solution, which organizations of all sizes are already enjoying.

Start your 21-day free trial

Discover the benefits of our Continuous Hacking solution, which organizations of all sizes are already enjoying.

Start your 21-day free trial

Discover the benefits of our Continuous Hacking solution, which organizations of all sizes are already enjoying.

Fluid Attacks' solutions enable organizations to identify, prioritize, and remediate vulnerabilities in their software throughout the SDLC. Supported by AI, automated tools, and pentesters, Fluid Attacks accelerates companies' risk exposure mitigation and strengthens their cybersecurity posture.

SOC 2 Type II

SOC 3

Subscribe to our newsletter

Stay updated on our upcoming events and latest blog posts, advisories and other engaging resources.

© 2025 Fluid Attacks. We hack your software.

Fluid Attacks' solutions enable organizations to identify, prioritize, and remediate vulnerabilities in their software throughout the SDLC. Supported by AI, automated tools, and pentesters, Fluid Attacks accelerates companies' risk exposure mitigation and strengthens their cybersecurity posture.

SOC 2 Type II

SOC 3

Subscribe to our newsletter

Stay updated on our upcoming events and latest blog posts, advisories and other engaging resources.

© 2025 Fluid Attacks. We hack your software.

Fluid Attacks' solutions enable organizations to identify, prioritize, and remediate vulnerabilities in their software throughout the SDLC. Supported by AI, automated tools, and pentesters, Fluid Attacks accelerates companies' risk exposure mitigation and strengthens their cybersecurity posture.

SOC 2 Type II

SOC 3

Subscribe to our newsletter

Stay updated on our upcoming events and latest blog posts, advisories and other engaging resources.

© 2025 Fluid Attacks. We hack your software.