GHSA-mvrp-3cvx-c325 Zod denial of service vulnerability during email validation

Not scored Published

Attackers can cause denial of service in API servers using Zod email validation via inefficient regex complexity.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is GHSA-mvrp-3cvx-c325?

GHSA-mvrp-3cvx-c325 is a denial of service vulnerability in express-zod-api, published on 4 Oct 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

Impact

API servers running express-zod-api having:

  • version of express-zod-api below 10.0.0-beta1,
  • and using the following (or similar) validation schema in its implementation: z.string().email(),

are vulnerable to a DoS attack due to:

  • Inefficient Regular Expression Complexity in zod versions up to 3.22.2,
  • depending on zod.

Patches

The patched version of zod fixing the vulnerability is 3.22.3.

However, it's highly recommended to upgrade express-zod-api to at least version 10.0.0, which does not depend on zod strictly and directly, but requires its installation as a peer dependency instead, enabling you to install the patched zod version yourself.

Workarounds

When it's not possible to upgrade your dependencies, consider the following replacement in your implementation:

- z.string().email()
+ z.string().regex(
+   /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i
+ )

This regular expression is taken from the suggested patch of zod.

References

Which versions are affected by GHSA-mvrp-3cvx-c325?

2 open source packages ship an affected version, including express-zod-api.

PackageAffectedFixed in
express-zod-api npmAll versions10.0.0-beta1
express-zod-api npmAll versions10.0.0-beta1

How do I fix GHSA-mvrp-3cvx-c325?

Upgrade express-zod-api to 10.0.0-beta1 or later.

Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.

Is GHSA-mvrp-3cvx-c325 being exploited?

There is no known exploitation of GHSA-mvrp-3cvx-c325 in the wild and no public exploit code.

Sources

Is GHSA-mvrp-3cvx-c325 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free