Vulnerabilities in pkg:npm/express-zod-api

PACKAGE
Advisory Summary

GHSA-mvrp-3cvx-c325 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Express zod api libraries in the npm ecosystem. The issue involves zod denial of service vulnerability during email validation. Remediation is available by upgrading affected packages to version 10.0.0-beta1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/express-zod-api

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/express-zod-api. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-mvrp-3cvx-c325 - HIGH Zod denial of service vulnerability during email validation

GHSA-mvrp-3cvx-c325 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-mvrp-3cvx-c325
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Express zod api
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix GHSA-mvrp-3cvx-c325

To remediate this vulnerability, upgrade all affected Express zod api dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

express-zod-api fixed: 10.0.0-beta1
npm install express-zod-api@10.0.0-beta1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls express-zod-api

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-mvrp-3cvx-c325, inspect your project dependencies using npm:

npm ls express-zod-api

Analyze the terminal output to locate any version of Express zod api in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 10.0.0-beta1), your application is affected.

Note: The npm ls express-zod-api command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Express zod api, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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: ```diff - 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 - Original issue: https://github.com/colinhacks/zod/issues/2609 - The patch: https://github.com/colinhacks/zod/pull/2824 - Entry in database: https://nvd.nist.gov/vuln/detail/CVE-2023-4316 - Enumeration: https://cwe.mitre.org/data/definitions/1333.html - Parent advisory: https://github.com/advisories/GHSA-m95q-7qp3-xv42 - Changelog entry for `express-zod-api` version `10.0.0-beta1`: https://github.com/RobinTail/express-zod-api/blob/master/CHANGELOG.md#v1000-beta1

GHSA-mvrp-3cvx-c325 Affected Express zod api Versions

1 component(s)
Fixed Versions:
10.0.0-beta1
Product / Package Ecosystem Affected Versions Fixed Version
express-zod-api
npm
< 10.0.0-beta1
10.0.0-beta1

References

Frequently Asked Questions

What is GHSA-mvrp-3cvx-c325?
GHSA-mvrp-3cvx-c325 is a security vulnerability in Express zod api involving Zod denial of service vulnerability during email validation under CWE-1333: Inefficient Regular Expression Complexity.
Which Express zod api versions are affected?
Affected versions include releases prior to 10.0.0-beta1 across affected packages: express-zod-api.
What version fixes GHSA-mvrp-3cvx-c325?
Upgrading to 10.0.0-beta1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is express-zod-api affected?
Yes, express-zod-api is affected in releases prior to 10.0.0-beta1. Upgrade your dependency to 10.0.0-beta1 or later.
What is the CVSS score of GHSA-mvrp-3cvx-c325?
GHSA-mvrp-3cvx-c325 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with GHSA-mvrp-3cvx-c325?
GHSA-mvrp-3cvx-c325 is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check npm dependencies for GHSA-mvrp-3cvx-c325?
Run the dependency tree command: 'npm ls express-zod-api'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mvrp-3cvx-c325",
  "modified" : "2023-10-04T14:46:06Z",
  "published" : "2023-10-04T14:46:06Z",
  "aliases" : [ ],
  "summary" : "Zod denial of service vulnerability during email validation",
  "details" : "### Impact\n\nAPI servers running `express-zod-api` having:\n\n- version of `express-zod-api` below `10.0.0-beta1`,\n- and using the following (or similar) validation schema in its implementation: `z.string().email()`,\n\nare vulnerable to a DoS attack due to: \n\n- Inefficient Regular Expression Complexity in `zod` versions up to `3.22.2`,\n- depending on `zod`.\n\n### Patches\n\nThe patched version of `zod` fixing the vulnerability is `3.22.3`.\n\nHowever, 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.\n\n### Workarounds\n\nWhen it's not possible to upgrade your dependencies, consider the following replacement in your implementation:\n\n```diff\n- z.string().email()\n+ z.string().regex(\n+   /^(?!\\.)(?!.*\\.\\.)([A-Z0-9_+-\\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\\-]*\\.)+[A-Z]{2,}$/i\n+ )\n```\n\nThis regular expression is taken from the suggested patch of `zod`.\n\n### References\n\n- Original issue: https://github.com/colinhacks/zod/issues/2609\n- The patch: https://github.com/colinhacks/zod/pull/2824\n- Entry in database: https://nvd.nist.gov/vuln/detail/CVE-2023-4316\n- Enumeration: https://cwe.mitre.org/data/definitions/1333.html\n- Parent advisory: https://github.com/advisories/GHSA-m95q-7qp3-xv42\n- Changelog entry for `express-zod-api` version `10.0.0-beta1`: https://github.com/RobinTail/express-zod-api/blob/master/CHANGELOG.md#v1000-beta1",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "express-zod-api"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "10.0.0-beta1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/RobinTail/express-zod-api/security/advisories/GHSA-mvrp-3cvx-c325"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/colinhacks/zod/issues/2609"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/colinhacks/zod/pull/2824"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/RobinTail/express-zod-api"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-m95q-7qp3-xv42"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-10-04T14:46:06Z",
    "nvd_published_at" : null
  }
}